diff options
author | The Bundler Bot <bot@bundler.io> | 2018-06-20 04:17:46 +0000 |
---|---|---|
committer | Colby Swandale <hello@colby.fyi> | 2018-07-10 23:02:45 +1000 |
commit | 912fbb8c7c1b876af78d404c57b790ffc87815bf (patch) | |
tree | 75d186fd4fec8ab11fc831217735460f56a8c3e9 | |
parent | 8da65ba7cabc881c2a4f571ebcd18a5ce1a1a238 (diff) | |
download | bundler-912fbb8c7c1b876af78d404c57b790ffc87815bf.tar.gz |
Auto merge of #6583 - bundler:skip-remove-auth-with-file-protocol, r=segiddins
Support URI::File of Ruby 2.6
### What was the end-user problem that led to this PR?
When users use file protocol with bundler, URI of Ruby 2.6 will raise auth info assignment and normalize host parameter given localhost variable with its case.
### Why did you choose this fix out of the possible options?
URI behavior of Ruby 2.6 is reasonable for me. Because I will fix this problem on bundler side.
(cherry picked from commit c3e00619a5ce34ef14b57b33278f13969ac276e7)
-rw-r--r-- | lib/bundler/source/rubygems.rb | 6 | ||||
-rw-r--r-- | lib/bundler/source/rubygems/remote.rb | 5 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/install_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/failure_spec.rb | 4 | ||||
-rw-r--r-- | spec/install/gemfile/gemspec_spec.rb | 12 | ||||
-rw-r--r-- | spec/install/gemfile/sources_spec.rb | 8 | ||||
-rw-r--r-- | spec/install/gems/mirror_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/post_bundle_message_spec.rb | 2 | ||||
-rw-r--r-- | spec/lock/lockfile_bundler_1_spec.rb | 2 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers.rb | 9 | ||||
-rw-r--r-- | spec/support/matchers.rb | 2 |
15 files changed, 44 insertions, 26 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 6213780556..485b388a32 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -338,7 +338,11 @@ module Bundler end def remove_auth(remote) - remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s + if remote.user || remote.password + remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s + else + remote.to_s + end end def installed_specs diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb index e73baaa992..b45f33770a 100644 --- a/lib/bundler/source/rubygems/remote.rb +++ b/lib/bundler/source/rubygems/remote.rb @@ -25,7 +25,10 @@ module Bundler cache_uri = original_uri || uri - uri_parts = [cache_uri.host, cache_uri.user, cache_uri.port, cache_uri.path] + # URI::File of Ruby 2.6 returns empty string when given "file://". + host = defined?(URI::File) && cache_uri.is_a?(URI::File) ? nil : cache_uri.host + + uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path] uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join(".")) uri_parts[-1] = uri_digest diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 0df25da5bb..03212fd9b3 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -789,6 +789,8 @@ __FILE__: #{path.to_s.inspect} end it "overrides disable_shared_gems so bundler can be found" do + skip "bundler 1.16.x is not support with Ruby 2.6 on Travis CI" if RUBY_VERSION >= "2.6" + file = bundled_app("file_that_bundle_execs.rb") create_file(file, <<-RB) #!#{Gem.ruby} diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index b6e89d70da..85593ee0ff 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -355,7 +355,7 @@ RSpec.describe "bundle install with gem sources" do expect(last_command.stdboth).not_to match(/Error Report/i) expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). - and include("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.") + and include(normalize_uri_file("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.")) end it "doesn't blow up when the local .bundle/config is empty" do diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index b31d54c962..0b77605f01 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "bundle lock" do gem "foo" G - @lockfile = strip_lockfile <<-L + @lockfile = strip_lockfile(normalize_uri_file(<<-L)) GEM remote: file://localhost#{repo}/ specs: @@ -244,7 +244,7 @@ RSpec.describe "bundle lock" do simulate_platform(mingw) { bundle! :lock } - expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G)) + expect(the_bundle.lockfile).to read_as(normalize_uri_file(strip_whitespace(<<-G))) GEM remote: file://localhost#{gem_repo4}/ specs: @@ -269,7 +269,7 @@ RSpec.describe "bundle lock" do simulate_platform(rb) { bundle! :lock } - expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G)) + expect(the_bundle.lockfile).to read_as(normalize_uri_file(strip_whitespace(<<-G))) GEM remote: file://localhost#{gem_repo4}/ specs: diff --git a/spec/install/failure_spec.rb b/spec/install/failure_spec.rb index 2c0c84e771..b4cdf13857 100644 --- a/spec/install/failure_spec.rb +++ b/spec/install/failure_spec.rb @@ -18,7 +18,7 @@ RSpec.describe "bundle install" do source "file:\/\/localhost#{gem_repo2}" gem "rails" G - expect(last_command.bundler_err).to end_with(<<-M.strip) + expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip)) An error occurred while installing activesupport (2.3.2), and Bundler cannot continue. Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling. @@ -111,7 +111,7 @@ In Gemfile: gem "rails" end G - expect(last_command.bundler_err).to end_with(<<-M.strip) + expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip)) An error occurred while installing activesupport (2.3.2), and Bundler cannot continue. Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling. diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index 86cd2d8f3f..7ce037730e 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -442,7 +442,7 @@ RSpec.describe "bundle install from an existing gemspec" do context "as a runtime dependency" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) PATH remote: . specs: @@ -473,7 +473,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) PATH remote: . specs: @@ -505,7 +505,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) PATH remote: . specs: @@ -543,7 +543,7 @@ RSpec.describe "bundle install from an existing gemspec" do context "as a runtime dependency" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) GEM remote: file://localhost#{gem_repo2}/ specs: @@ -574,7 +574,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) GEM remote: file://localhost#{gem_repo2}/ specs: @@ -606,7 +606,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "keeps java dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY" - expect(lockfile).to eq strip_whitespace(<<-L) + expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L)) GEM remote: file://localhost#{gem_repo2}/ specs: diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb index 44696f89d2..1c477e33a3 100644 --- a/spec/install/gemfile/sources_spec.rb +++ b/spec/install/gemfile/sources_spec.rb @@ -33,7 +33,7 @@ RSpec.describe "bundle install with gems on multiple sources" do expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(out).to include("Installed from: file://localhost#{gem_repo1}") + expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}")) expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1") end @@ -63,7 +63,7 @@ RSpec.describe "bundle install with gems on multiple sources" do expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(out).to include("Installed from: file://localhost#{gem_repo1}") + expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}")) expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1") end end @@ -253,7 +253,7 @@ RSpec.describe "bundle install with gems on multiple sources" do bundle :install expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(out).to include("Installed from: file://localhost#{gem_repo2}") + expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}")) expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0") end end @@ -634,7 +634,7 @@ RSpec.describe "bundle install with gems on multiple sources" do gem "depends_on_rack" G expect(last_command).to be_failure - expect(last_command.stderr).to eq strip_whitespace(<<-EOS).strip + expect(last_command.stderr).to eq normalize_uri_file(strip_whitespace(<<-EOS).strip) The gem 'rack' was found in multiple relevant sources. * rubygems repository file://localhost#{gem_repo1}/ or installed locally * rubygems repository file://localhost#{gem_repo4}/ or installed locally diff --git a/spec/install/gems/mirror_spec.rb b/spec/install/gems/mirror_spec.rb index 89302615f1..4c35b8f206 100644 --- a/spec/install/gems/mirror_spec.rb +++ b/spec/install/gems/mirror_spec.rb @@ -13,7 +13,7 @@ RSpec.describe "bundle install with a mirror configured" do it "installs from the normal location" do bundle :install - expect(out).to include("Fetching source index from file://localhost#{gem_repo1}") + expect(out).to include(normalize_uri_file("Fetching source index from file://localhost#{gem_repo1}")) expect(the_bundle).to include_gems "rack 1.0" end end @@ -31,8 +31,8 @@ RSpec.describe "bundle install with a mirror configured" do it "installs the gem from the mirror" do bundle :install - expect(out).to include("Fetching source index from file://localhost#{gem_repo1}") - expect(out).not_to include("Fetching source index from file://localhost#{gem_repo2}") + expect(out).to include(normalize_uri_file("Fetching source index from file://localhost#{gem_repo1}")) + expect(out).not_to include(normalize_uri_file("Fetching source index from file://localhost#{gem_repo2}")) expect(the_bundle).to include_gems "rack 1.0" end end diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb index 53a93845c2..eadc8a4d85 100644 --- a/spec/install/post_bundle_message_spec.rb +++ b/spec/install/post_bundle_message_spec.rb @@ -116,7 +116,7 @@ RSpec.describe "post bundle message" do gem "rack" gem "not-a-gem", :group => :development G - expect(out).to include <<-EOS.strip + expect(out).to include normalize_uri_file(<<-EOS.strip) Could not find gem 'not-a-gem' in rubygems repository file://localhost#{gem_repo1}/ or installed locally. The source does not contain any versions of 'not-a-gem' EOS diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index 233e3f63c4..a8615d4c89 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -1240,7 +1240,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do expect(the_bundle).to include_gems "omg 1.0" # Confirm that duplicate specs do not appear - expect(File.read(bundled_app("Gemfile.lock"))).to eq(strip_whitespace(<<-L)) + lockfile_should_be(<<-L) GIT remote: #{lib_path("omg")} revision: #{revision} diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 5be77de7ef..53c832445f 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -1279,7 +1279,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do expect(the_bundle).to include_gems "omg 1.0" # Confirm that duplicate specs do not appear - expect(File.read(bundled_app("Gemfile.lock"))).to eq(strip_whitespace(<<-L)) + lockfile_should_be(<<-L) GEM remote: file://localhost#{gem_repo1}/ specs: diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index e41bfdf32c..c0a18eb124 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1170,7 +1170,7 @@ end #{Bundler::VERSION} L - lock + normalize_uri_file(lock) end before do diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 1b52ed5258..fbc7cdadc6 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -280,6 +280,15 @@ module Spec str.gsub(/^#{spaces}/, "") end + def normalize_uri_file(str) + # URI::File of Ruby 2.6 normalize localhost variable with file protocol. + if defined?(URI::File) + str.gsub(%r{file:\/\/localhost}, "file://") + else + str + end + end + def install_gemfile(*args) gemfile(*args) opts = args.last.is_a?(Hash) ? args.last : {} diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 782257a222..0244927bdc 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -236,7 +236,7 @@ module Spec end def lockfile_should_be(expected) - expect(bundled_app("Gemfile.lock")).to read_as(strip_whitespace(expected)) + expect(bundled_app("Gemfile.lock")).to read_as(normalize_uri_file(strip_whitespace(expected))) end end end |