1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] Fix file:// handling under Windows

Windows paths do not start with a slash, so we add an extra slash to
separate the host from the path in file:// urls. Otherwise "D:" is
parsed as the host segment in the URI.

The path for those URLs now starts with "/", so we ignore that leading
character when using the URI's path.

This reduces Windows CI spec failures from 429 to 355.

https://github.com/bundler/bundler/commit/1b7e274cbc
This commit is contained in:
David Rodríguez 2019-05-05 19:00:47 +02:00 committed by Hiroshi SHIBATA
parent c3ddd47ce7
commit e111f38f34
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
3 changed files with 7 additions and 4 deletions

View file

@ -99,7 +99,8 @@ module Bundler
uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
if uri.scheme == "file"
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
path = Gem.win_platform? ? uri.path[1..-1] : uri.path
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else

View file

@ -30,7 +30,8 @@ module Bundler
uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
if uri.scheme == "file"
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
path = Gem.win_platform? ? uri.path[1..-1] : uri.path
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else

View file

@ -64,10 +64,11 @@ module Spec
def file_uri_for(path)
protocol = "file://"
root = Gem.win_platform? ? "/" : ""
return protocol + "localhost" + path.to_s if RUBY_VERSION < "2.5"
return protocol + "localhost" + root + path.to_s if RUBY_VERSION < "2.5"
protocol + path.to_s
protocol + root + path.to_s
end
def gem_repo1(*args)