diff options
author | The Bundler Bot <bot@bundler.io> | 2017-05-10 02:31:20 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-05-10 02:31:20 +0000 |
commit | e437521b495895149a3ef0b5f63b629d6b045d61 (patch) | |
tree | 372cbf3f7632afd9fedfe2980fcc2963b6eb5549 | |
parent | 302c32def754563d800688bf620d21ed3eef11e0 (diff) | |
parent | da702da525174286947831d5f8ececbc01fdf5c6 (diff) | |
download | bundler-e437521b495895149a3ef0b5f63b629d6b045d61.tar.gz |
Auto merge of #5650 - bundler:seg-mirror-file-uri-case, r=indirect
[Mirror] Properly handle casing of file URIs
This came up when running the bundler specs in a path that had at least 1 upper case character
```
Run options:
include {:last_run_status=>"failed"}
exclude {:rubygems_master=>true, :git=>"=< 2.9.0", :rubygems=>"=< 2.6.12", :ruby=>"=< 2.3.1", :realworld=>true, :sudo=>true}
bundle install
with bundler dependencies
$ /Users/kenrettberg/.rbenv/versions/2.3.1/bin/ruby -rubygems -S gem --backtrace generate_index
Generating Marshal quick index gemspecs for 64 gems
................................................................
Complete
Generated Marshal quick index gemspecs: 0.036s
Generating specs index
Generated specs index: 0.000s
Generating latest specs index
Generated latest specs index: 0.000s
Generating prerelease specs index
Generated prerelease specs index: 0.000s
Compressing indices
Compressed indices: 0.001s
# $? => 0
$ /Users/kenrettberg/.rbenv/versions/2.3.1/bin/ruby -I/Users/kenrettberg/opensource/bundler/lib:/Users/kenrettberg/opensource/bundler/spec -r/Users/kenrettberg/opensource/bundler/spec/support/artifice/fail.rb -rsupport/hax /Users/kenrettberg/opensource/bundler/exe/bundle install --retry 0 --no-color
Fetching source index from file:/users/kenrettberg/opensource/bundler/tmp/gems/remote2/
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (= 0.9.2)
Current Bundler version:
bundler (1.15.0.pre.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (= 0.9.2)' in any of the sources
# $? => 6
causes a conflict if explicitly requesting a different version (FAILED - 1)
Retried examples: 0
Failures:
1) bundle install with bundler dependencies causes a conflict if explicitly requesting a different version
Failure/Error: expect(out).to eq(nice_error)
expected: "Fetching source index from file:/Users/kenrettberg/opensource/bundler/tmp/gems/remote2/\nResolving d...r by running `gem install bundler`?\n\nCould not find gem 'bundler (= 0.9.2)' in any of the sources"
got: "Fetching source index from file:/users/kenrettberg/opensource/bundler/tmp/gems/remote2/\nResolving d...r by running `gem install bundler`?\n\nCould not find gem 'bundler (= 0.9.2)' in any of the sources"
(compared using ==)
Diff:
@@ -1,4 +1,4 @@
-Fetching source index from file:/Users/kenrettberg/opensource/bundler/tmp/gems/remote2/
+Fetching source index from file:/users/kenrettberg/opensource/bundler/tmp/gems/remote2/
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
Commands:
$ /Users/kenrettberg/.rbenv/versions/2.3.1/bin/ruby -rubygems -S gem --backtrace generate_index
Generating Marshal quick index gemspecs for 64 gems
................................................................
Complete
Generated Marshal quick index gemspecs: 0.036s
Generating specs index
Generated specs index: 0.000s
Generating latest specs index
Generated latest specs index: 0.000s
Generating prerelease specs index
Generated prerelease specs index: 0.000s
Compressing indices
Compressed indices: 0.001s
# $? => 0
$ /Users/kenrettberg/.rbenv/versions/2.3.1/bin/ruby -I/Users/kenrettberg/opensource/bundler/lib:/Users/kenrettberg/opensource/bundler/spec -r/Users/kenrettberg/opensource/bundler/spec/support/artifice/fail.rb -rsupport/hax /Users/kenrettberg/opensource/bundler/exe/bundle install --retry 0 --no-color
Fetching source index from file:/users/kenrettberg/opensource/bundler/tmp/gems/remote2/
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (= 0.9.2)
Current Bundler version:
bundler (1.15.0.pre.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (= 0.9.2)' in any of the sources
# $? => 6
# ./spec/install/bundler_spec.rb:54:in `block (3 levels) in <top (required)>'
Finished in 2.4 seconds (files took 1.66 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/install/bundler_spec.rb:33 # bundle install with bundler dependencies causes a conflict if explicitly requesting a different version
```
Notice the failure is just in the casing of the path... but that path is actually a file URI that is printed by a `Mirror` instance. Tracing back that initialization led me to undoing some down casing, so hopefully this is more correct without introducing any further regressions?
-rw-r--r-- | lib/bundler/mirror.rb | 5 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | spec/bundler/settings_spec.rb | 16 |
3 files changed, 20 insertions, 3 deletions
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb index 9903e158ab..8a081ba91f 100644 --- a/lib/bundler/mirror.rb +++ b/lib/bundler/mirror.rb @@ -45,7 +45,8 @@ module Bundler private def fetch_valid_mirror_for(uri) - mirror = @mirrors[uri.to_s.downcase] || @mirrors[URI(uri.to_s).host] || Mirror.new(uri) + downcased = uri.to_s.downcase + mirror = @mirrors[downcased] || @mirrors[URI(downcased).host] || Mirror.new(uri) mirror.validate!(@prober) mirror = Mirror.new(uri) unless mirror.valid? mirror @@ -72,7 +73,7 @@ module Bundler @uri = if uri.nil? nil else - URI(uri.to_s.downcase) + URI(uri.to_s) end @valid = nil end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 81cbb3953c..62c21a2ecb 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -344,7 +344,7 @@ module Bundler unless uri.absolute? raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri) end - "#{prefix}#{uri}#{suffix}".downcase + "#{prefix}#{uri}#{suffix}" end end end diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index ec01827500..a93c41b7d2 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -184,6 +184,22 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow it "is case insensitive" do expect(settings.mirror_for("HTTPS://RUBYGEMS.ORG/")).to eq(mirror_uri) end + + context "with a file URI" do + let(:mirror_uri) { URI("file:/foo/BAR/baz/qUx/") } + + it "returns the mirror URI" do + expect(settings.mirror_for(uri)).to eq(mirror_uri) + end + + it "converts a string parameter to a URI" do + expect(settings.mirror_for("file:/foo/BAR/baz/qUx/")).to eq(mirror_uri) + end + + it "normalizes the URI" do + expect(settings.mirror_for("file:/foo/BAR/baz/qUx")).to eq(mirror_uri) + end + end end end |