diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-06-14 12:55:03 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-07-07 10:03:15 +0900 |
commit | d4b4281959d2a9846d766253b5e21e8158948aa7 (patch) | |
tree | 64f45489cd78b781b682e2a94c16a6829b8f2edd /spec | |
parent | dd28c03d5fd7a82d1b694a9c2332a55dab81add9 (diff) |
Merge RubyGems-3.2.18 and Bundler-2.2.18
Diffstat (limited to 'spec')
42 files changed, 732 insertions, 701 deletions
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index dcdde75315..67a1536541 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -268,33 +268,6 @@ RSpec.describe Bundler::Definition do end end - describe "find_resolved_spec" do - it "with no platform set in SpecSet" do - ss = Bundler::SpecSet.new([build_stub_spec("a", "1.0"), build_stub_spec("b", "1.0")]) - dfn = Bundler::Definition.new(nil, [], mock_source_list, true) - dfn.instance_variable_set("@specs", ss) - found = dfn.find_resolved_spec(build_spec("a", "0.9", "ruby").first) - expect(found.name).to eq "a" - expect(found.version.to_s).to eq "1.0" - end - end - - describe "find_indexed_specs" do - it "with no platform set in indexed specs" do - index = Bundler::Index.new - %w[1.0.0 1.0.1 1.1.0].each {|v| index << build_stub_spec("foo", v) } - - dfn = Bundler::Definition.new(nil, [], mock_source_list, true) - dfn.instance_variable_set("@index", index) - found = dfn.find_indexed_specs(build_spec("foo", "0.9", "ruby").first) - expect(found.length).to eq 3 - end - end - - def build_stub_spec(name, version) - Bundler::StubSpecification.new(name, version, nil, nil) - end - def mock_source_list Class.new do def all_sources diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index f8fab594b8..3816649141 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -234,7 +234,7 @@ RSpec.describe "bundle cache" do end end - bundle "config --local without wo" + bundle "config set --local without wo" install_gemfile <<-G source "file:#{gem_repo1}" gem "rack" @@ -250,7 +250,7 @@ RSpec.describe "bundle cache" do expect(the_bundle).to include_gem "rack 1.0" expect(the_bundle).not_to include_gems "weakling", "uninstallable" - bundle "config --local without wo" + bundle "config set --local without wo" bundle :install expect(the_bundle).to include_gem "rack 1.0" expect(the_bundle).not_to include_gems "weakling", "uninstallable" @@ -282,7 +282,7 @@ RSpec.describe "bundle cache" do end subject do - bundle "config --local frozen true" + bundle "config set --local frozen true" bundle :cache, :raise_on_error => false end @@ -332,8 +332,8 @@ RSpec.describe "bundle install with gem sources" do simulate_new_machine FileUtils.rm_rf gem_repo2 - bundle "config --local deployment true" - bundle "config --local path vendor/bundle" + bundle "config set --local deployment true" + bundle "config set --local path vendor/bundle" bundle :install expect(the_bundle).to include_gems "rack 1.0.0" end diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index fdf3bc7d51..2fb03186be 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -124,7 +124,7 @@ RSpec.describe "bundle check" do gem "rack", :group => :foo G - bundle "config --local without foo" + bundle "config set --local without foo" bundle :install gemfile <<-G @@ -217,7 +217,7 @@ RSpec.describe "bundle check" do gem "foo" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle "install" FileUtils.rm(bundled_app_lock) diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 33677cf4ad..2f4488a552 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -45,7 +45,7 @@ RSpec.describe ".bundle/config" do it "can be moved with an environment variable" do ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle "install" expect(bundled_app(".bundle")).not_to exist @@ -57,7 +57,7 @@ RSpec.describe ".bundle/config" do FileUtils.mkdir_p bundled_app("omg") ENV["BUNDLE_APP_CONFIG"] = "../foo" - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle "install", :dir => bundled_app("omg") expect(bundled_app(".bundle")).not_to exist diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 5fa68b96d5..0d104ad304 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -295,7 +295,7 @@ RSpec.describe "bundle exec" do end it "handles gems installed with --without" do - bundle "config --local without middleware" + bundle "config set --local without middleware" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" # rack 0.9.1 and 1.0 exist diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index f12d32d6a8..c91864dbb8 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -291,7 +291,7 @@ RSpec.describe "bundle install with gem sources" do end it "works" do - bundle "config --local path vendor" + bundle "config set --local path vendor" bundle "install" expect(the_bundle).to include_gems "rack 1.0" end @@ -614,7 +614,7 @@ RSpec.describe "bundle install with gem sources" do it "should display a proper message to explain the problem" do FileUtils.chmod(0o500, cache_path) - bundle "config --local path vendor" + bundle "config set --local path vendor" bundle :install, :raise_on_error => false expect(err).to include(cache_path.to_s) expect(err).to include("grant write permissions") @@ -627,7 +627,7 @@ RSpec.describe "bundle install with gem sources" do source "#{file_uri_for(gem_repo1)}" gem "rack" G - bundle "config --local path bundle" + bundle "config set --local path bundle" bundle "install", :standalone => true end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 264af30f6c..21eb6e5456 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -533,7 +533,7 @@ RSpec.describe "bundle lock" do #{Bundler::VERSION} L - bundle "lock --add-platform x86_64-linux", :artifice => :compact_index, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + bundle "lock --add-platform x86_64-linux", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } end context "when an update is available" do diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index b0f0448655..fd54e18b6c 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -205,8 +205,8 @@ RSpec.describe "bundle outdated" do end it "works" do - bundle :install, :artifice => :compact_index - bundle :outdated, :artifice => :compact_index, :raise_on_error => false + bundle :install, :artifice => "compact_index" + bundle :outdated, :artifice => "compact_index", :raise_on_error => false expected_output = <<~TABLE Gem Current Latest Requested Groups diff --git a/spec/bundler/commands/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb index 3092f9a9b7..72f8020b44 100644 --- a/spec/bundler/commands/post_bundle_message_spec.rb +++ b/spec/bundler/commands/post_bundle_message_spec.rb @@ -29,21 +29,21 @@ RSpec.describe "post bundle message" do expect(out).to include(bundle_complete_message) expect(out).to include(installed_gems_stats) - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(out).to include(bundle_show_message) expect(out).to include("Gems in the group 'emo' were not installed") expect(out).to include(bundle_complete_message) expect(out).to include(installed_gems_stats) - bundle "config --local without emo test" + bundle "config set --local without emo test" bundle :install expect(out).to include(bundle_show_message) expect(out).to include("Gems in the groups 'emo' and 'test' were not installed") expect(out).to include(bundle_complete_message) expect(out).to include("4 Gemfile dependencies, 3 gems now installed.") - bundle "config --local without emo obama test" + bundle "config set --local without emo obama test" bundle :install expect(out).to include(bundle_show_message) expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed") @@ -55,28 +55,28 @@ RSpec.describe "post bundle message" do let(:bundle_path) { "./vendor" } it "shows proper messages according to the configured groups" do - bundle "config --local path vendor" + bundle "config set --local path vendor" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to_not include("Gems in the group") expect(out).to include(bundle_complete_message) - bundle "config --local path vendor" - bundle "config --local without emo" + bundle "config set --local path vendor" + bundle "config set --local without emo" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the group 'emo' were not installed") expect(out).to include(bundle_complete_message) - bundle "config --local path vendor" - bundle "config --local without emo test" + bundle "config set --local path vendor" + bundle "config set --local without emo test" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the groups 'emo' and 'test' were not installed") expect(out).to include(bundle_complete_message) - bundle "config --local path vendor" - bundle "config --local without emo obama test" + bundle "config set --local path vendor" + bundle "config set --local without emo obama test" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed") @@ -88,7 +88,7 @@ RSpec.describe "post bundle message" do let(:bundle_path) { bundled_app("cache") } it "shows proper messages according to the configured groups" do - bundle "config --local path #{bundle_path}" + bundle "config set --local path #{bundle_path}" bundle :install expect(out).to include("Bundled gems are installed into `./cache`") expect(out).to_not include("Gems in the group") @@ -100,7 +100,7 @@ RSpec.describe "post bundle message" do let(:bundle_path) { tmp("not_bundled_app") } it "shows proper messages according to the configured groups" do - bundle "config --local path #{bundle_path}" + bundle "config set --local path #{bundle_path}" bundle :install expect(out).to include("Bundled gems are installed into `#{tmp("not_bundled_app")}`") expect(out).to_not include("Gems in the group") @@ -184,19 +184,19 @@ The source does not contain any versions of 'not-a-gem' expect(out).not_to include("Gems in the groups") expect(out).to include(bundle_updated_message) - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install bundle :update, :all => true expect(out).to include("Gems in the group 'emo' were not updated") expect(out).to include(bundle_updated_message) - bundle "config --local without emo test" + bundle "config set --local without emo test" bundle :install bundle :update, :all => true expect(out).to include("Gems in the groups 'emo' and 'test' were not updated") expect(out).to include(bundle_updated_message) - bundle "config --local without emo obama test" + bundle "config set --local without emo obama test" bundle :install bundle :update, :all => true expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not updated") diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 51a0b925a3..4d5bab063d 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -649,8 +649,8 @@ RSpec.describe "bundle update" do end it "works" do - bundle :install, :artifice => :compact_index - bundle "update oj", :artifice => :compact_index + bundle :install, :artifice => "compact_index" + bundle "update oj", :artifice => "compact_index" expect(out).to include("Bundle updated!") expect(the_bundle).to include_gems "oj 3.11.5" diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 3e3bbe816f..8f6298b301 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -44,8 +44,8 @@ RSpec.describe "install in deployment or frozen mode" do it "still works if you are not in the app directory and specify --gemfile" do bundle "install" simulate_new_machine - bundle "config --local deployment true" - bundle "config --local path vendor/bundle" + bundle "config set --local deployment true" + bundle "config set --local path vendor/bundle" bundle "install --gemfile #{tmp}/bundled_app/Gemfile", :dir => tmp expect(the_bundle).to include_gems "rack 1.0" end @@ -58,8 +58,8 @@ RSpec.describe "install in deployment or frozen mode" do end G bundle :install - bundle "config --local deployment true" - bundle "config --local without test" + bundle "config set --local deployment true" + bundle "config set --local without test" bundle :install end @@ -67,7 +67,7 @@ RSpec.describe "install in deployment or frozen mode" do skip "doesn't find bundle" if Gem.win_platform? bundle :install - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install bundle "exec bundle check", :env => { "PATH" => path } end @@ -81,7 +81,7 @@ RSpec.describe "install in deployment or frozen mode" do G bundle :install - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install end @@ -104,7 +104,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "rack-obama", ">= 1.0" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "endpoint_strict_basic_authentication" end @@ -115,7 +115,7 @@ RSpec.describe "install in deployment or frozen mode" do end G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install expect(the_bundle).to include_gems "rack 1.0" @@ -123,7 +123,7 @@ RSpec.describe "install in deployment or frozen mode" do context "when replacing a host with the same host with credentials" do before do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle "install" gemfile <<-G source "http://user_name:password@localgemserver.test/" @@ -227,7 +227,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "rack-obama" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") expect(err).to include("You have added to the Gemfile") @@ -246,9 +246,9 @@ RSpec.describe "install in deployment or frozen mode" do expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle "config --local path .bundle" - bundle "config --local without development" - bundle "config --local deployment true" + bundle "config set --local path .bundle" + bundle "config set --local without development" + bundle "config set --local deployment true" bundle :install, :env => { "DEBUG" => "1" } run "puts :WIN" expect(out).to eq("WIN") @@ -264,8 +264,8 @@ RSpec.describe "install in deployment or frozen mode" do expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle "config --local path .bundle" - bundle "config --local deployment true" + bundle "config set --local path .bundle" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.") end @@ -336,7 +336,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "activesupport" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") expect(err).to include("You have added to the Gemfile:\n* activesupport\n\n") @@ -350,7 +350,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "rack", :git => "git://hubz.com" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com") @@ -370,7 +370,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "rack" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")}") @@ -394,7 +394,7 @@ RSpec.describe "install in deployment or frozen mode" do gem "foo", :git => "#{lib_path("rack")}" G - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")}`") diff --git a/spec/bundler/install/gemfile/eval_gemfile_spec.rb b/spec/bundler/install/gemfile/eval_gemfile_spec.rb index c42ae7ef79..102f61dc12 100644 --- a/spec/bundler/install/gemfile/eval_gemfile_spec.rb +++ b/spec/bundler/install/gemfile/eval_gemfile_spec.rb @@ -47,7 +47,7 @@ RSpec.describe "bundle install with gemfile that uses eval_gemfile" do # parsed lockfile and the evaluated gemfile. it "bundles with deployment mode configured" do bundle :install - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install end end diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index b04db18f49..32dd7d24b8 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -291,7 +291,7 @@ RSpec.describe "bundle install from an existing gemspec" do s.add_dependency "activesupport", ">= 1.0.1" end - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("changed") @@ -557,7 +557,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "installs the ruby platform gemspec and skips dev deps with `without development` configured" do simulate_platform "ruby" - bundle "config --local without development" + bundle "config set --local without development" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gemspec :path => '#{tmp.join("foo")}', :name => 'foo' @@ -567,4 +567,57 @@ RSpec.describe "bundle install from an existing gemspec" do expect(the_bundle).not_to include_gem "rack" end end + + context "with multiple platforms and resolving for more specific platforms" do + before do + build_lib("chef", :path => tmp.join("chef")) do |s| + s.version = "17.1.17" + s.write "chef-universal-mingw32.gemspec", build_spec("chef", "17.1.17", "universal-mingw32") {|sw| sw.runtime "win32-api", "~> 1.5.3" }.first.to_ruby + end + end + + it "does not remove the platform specific specs from the lockfile when updating" do + build_repo4 do + build_gem "win32-api", "1.5.3" do |s| + s.platform = "universal-mingw32" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gemspec :path => "../chef" + G + + initial_lockfile = <<~L + PATH + remote: ../chef + specs: + chef (17.1.17) + chef (17.1.17-universal-mingw32) + win32-api (~> 1.5.3) + + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + win32-api (1.5.3-universal-mingw32) + + PLATFORMS + ruby + x64-mingw32 + x86-mingw32 + + DEPENDENCIES + chef! + + BUNDLED WITH + #{Bundler::VERSION} + L + + lockfile initial_lockfile + + bundle "update" + + expect(lockfile).to eq initial_lockfile + end + end end diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index 8477089608..ba8f253b0e 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -128,7 +128,7 @@ RSpec.describe "bundle install with git sources" do end it "still works after moving the application directory" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle "install" FileUtils.mv bundled_app, tmp("bundled_app.bck") @@ -137,7 +137,7 @@ RSpec.describe "bundle install with git sources" do end it "can still install after moving the application directory" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle "install" FileUtils.mv bundled_app, tmp("bundled_app.bck") @@ -1080,7 +1080,7 @@ RSpec.describe "bundle install with git sources" do simulate_new_machine - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install end end diff --git a/spec/bundler/install/gemfile/groups_spec.rb b/spec/bundler/install/gemfile/groups_spec.rb index 567a9b1172..c92b5dcc57 100644 --- a/spec/bundler/install/gemfile/groups_spec.rb +++ b/spec/bundler/install/gemfile/groups_spec.rb @@ -86,7 +86,7 @@ RSpec.describe "bundle install with groups" do end it "installs gems in the default group" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default] end @@ -117,7 +117,7 @@ RSpec.describe "bundle install with groups" do end it "does not install gems from the excluded group" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default] end @@ -130,13 +130,13 @@ RSpec.describe "bundle install with groups" do end it "does not say it installed gems from the excluded group" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(out).not_to include("activesupport") end it "allows Bundler.setup for specific groups" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install run("require 'rack'; puts RACK", :default) expect(out).to eq("1.0.0") @@ -151,7 +151,7 @@ RSpec.describe "bundle install with groups" do end G - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => [:default] end @@ -188,7 +188,7 @@ RSpec.describe "bundle install with groups" do end it "installs gems from the optional group when requested" do - bundle "config --local with debugging" + bundle "config set --local with debugging" bundle :install expect(the_bundle).to include_gems "thin 1.0" end @@ -214,13 +214,13 @@ RSpec.describe "bundle install with groups" do end it "removes groups from without when passed at --with", :bundler => "< 3" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle "install --with emo" expect(the_bundle).to include_gems "activesupport 2.3.5" end it "removes groups from with when passed at --without", :bundler => "< 3" do - bundle "config --local with debugging" + bundle "config set --local with debugging" bundle "install --without debugging", :raise_on_error => false expect(the_bundle).not_to include_gem "thin 1.0" end @@ -251,13 +251,13 @@ RSpec.describe "bundle install with groups" do end it "has no effect when listing a not optional group in with" do - bundle "config --local with emo" + bundle "config set --local with emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" end it "has no effect when listing an optional group in without" do - bundle "config --local without debugging" + bundle "config set --local without debugging" bundle :install expect(the_bundle).not_to include_gems "thin 1.0" end @@ -275,13 +275,13 @@ RSpec.describe "bundle install with groups" do end it "installs gems in the default group" do - bundle "config --local without emo lolercoaster" + bundle "config set --local without emo lolercoaster" bundle :install expect(the_bundle).to include_gems "rack 1.0.0" end it "installs the gem if any of its groups are installed" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5" end @@ -303,19 +303,19 @@ RSpec.describe "bundle install with groups" do end it "installs the gem unless all groups are excluded" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" - bundle "config --local without lolercoaster" + bundle "config set --local without lolercoaster" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" - bundle "config --local without emo lolercoaster" + bundle "config set --local without emo lolercoaster" bundle :install expect(the_bundle).not_to include_gems "activesupport 2.3.5" - bundle "config --local without 'emo lolercoaster'" + bundle "config set --local without 'emo lolercoaster'" bundle :install expect(the_bundle).not_to include_gems "activesupport 2.3.5" end @@ -336,13 +336,13 @@ RSpec.describe "bundle install with groups" do end it "installs gems in the default group" do - bundle "config --local without emo lolercoaster" + bundle "config set --local without emo lolercoaster" bundle :install expect(the_bundle).to include_gems "rack 1.0.0" end it "installs the gem if any of its groups are installed" do - bundle "config --local without emo" + bundle "config set --local without emo" bundle :install expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5" end @@ -358,7 +358,7 @@ RSpec.describe "bundle install with groups" do G ruby <<-R - require "#{lib_dir}/bundler" + require "#{entrypoint}" Bundler.setup :default Bundler.require :default puts RACK @@ -380,7 +380,7 @@ RSpec.describe "bundle install with groups" do system_gems "rack-0.9.1" - bundle "config --local without rack" + bundle "config set --local without rack" install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "rack" @@ -404,7 +404,7 @@ RSpec.describe "bundle install with groups" do it "does not hit the remote a second time" do FileUtils.rm_rf gem_repo2 - bundle "config --local without rack" + bundle "config set --local without rack" bundle :install, :verbose => true expect(last_command.stdboth).not_to match(/fetching/i) end diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 5772c4edc6..1c77b3a37e 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -131,7 +131,7 @@ RSpec.describe "bundle install with explicit source paths" do gem 'foo', :path => File.expand_path("../foo-1.0", __FILE__) G - bundle "config --local frozen true" + bundle "config set --local frozen true" bundle :install end diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb index 9b4bbba016..c49594183e 100644 --- a/spec/bundler/install/gemfile/platform_spec.rb +++ b/spec/bundler/install/gemfile/platform_spec.rb @@ -278,7 +278,7 @@ RSpec.describe "bundle install across platforms" do gem "rack", "1.0.0" G - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, "1.8")) diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb index bf150c115a..d13ba0e607 100644 --- a/spec/bundler/install/gemfile/sources_spec.rb +++ b/spec/bundler/install/gemfile/sources_spec.rb @@ -20,23 +20,23 @@ RSpec.describe "bundle install with gems on multiple sources" do before do gemfile <<-G - source "#{file_uri_for(gem_repo3)}" - source "#{file_uri_for(gem_repo1)}" + source "https://gem.repo3" + source "https://gem.repo1" gem "rack-obama" gem "rack" G end it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 3" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(err).to include("Installed from: #{file_uri_for(gem_repo1)}") + expect(err).to include("Installed from: https://gem.repo1") expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1") end it "fails", :bundler => "3" do - bundle :instal, :raise_on_error => false + bundle :instal, :artifice => "compact_index", :raise_on_error => false expect(err).to include("Each source after the first must include a block") expect(exitstatus).to eq(4) end @@ -47,22 +47,22 @@ RSpec.describe "bundle install with gems on multiple sources" do before do gemfile <<-G - source "#{file_uri_for(gem_repo3)}" - source "#{file_uri_for(gem_repo1)}" + source "https://gem.repo3" + source "https://gem.repo1" gem "rack-obama" gem "rack", "1.0.0" # force it to install the working version in repo1 G end it "warns about ambiguous gems, but installs anyway", :bundler => "< 3" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(err).to include("Installed from: #{file_uri_for(gem_repo1)}") + expect(err).to include("Installed from: https://gem.repo1") expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1") end it "fails", :bundler => "3" do - bundle :install, :raise_on_error => false + bundle :install, :artifice => "compact_index", :raise_on_error => false expect(err).to include("Each source after the first must include a block") expect(exitstatus).to eq(4) end @@ -85,8 +85,8 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo3)}" - source "#{file_uri_for(gem_repo1)}" do + source "https://gem.repo3" + source "https://gem.repo1" do gem "thin" # comes first to test name sorting gem "rack" end @@ -95,20 +95,20 @@ RSpec.describe "bundle install with gems on multiple sources" do end it "installs the gems without any warning" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning") expect(the_bundle).to include_gems("rack-obama 1.0.0") expect(the_bundle).to include_gems("rack 1.0.0", :source => "remote1") end it "can cache and deploy" do - bundle :cache + bundle :cache, :artifice => "compact_index" expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/rack-obama-1.0.gem")).to exist - bundle "config --local deployment true" - bundle :install + bundle "config set --local deployment true" + bundle :install, :artifice => "compact_index" expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0") end @@ -128,10 +128,10 @@ RSpec.describe "bundle install with gems on multiple sources" do end end - install_gemfile <<-G - source "#{file_uri_for(gem_repo3)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo3" gem "rack-obama" # should come from repo3! - gem "rack", :source => "#{file_uri_for(gem_repo1)}" + gem "rack", :source => "https://gem.repo1" G end @@ -155,8 +155,8 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo2" + source "https://gem.repo3" do gem "depends_on_rack" end G @@ -168,7 +168,7 @@ RSpec.describe "bundle install with gems on multiple sources" do end it "installs from the same source without any warning" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote3") end @@ -185,7 +185,7 @@ RSpec.describe "bundle install with gems on multiple sources" do end it "installs from the same source without any warning" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote3") @@ -193,7 +193,7 @@ RSpec.describe "bundle install with gems on multiple sources" do # In https://github.com/bundler/bundler/issues/3585 this failed # when there is already a lock file, and the gems are missing, so try again system_gems [] - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote3") @@ -218,9 +218,9 @@ RSpec.describe "bundle install with gems on multiple sources" do context "and not in any other sources" do before do - install_gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - source "#{file_uri_for(gem_repo3)}" do + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo2" + source "https://gem.repo3" do gem "depends_on_rack" end G @@ -235,23 +235,23 @@ RSpec.describe "bundle install with gems on multiple sources" do context "and in yet another source" do before do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - source "#{file_uri_for(gem_repo2)}" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo1" + source "https://gem.repo2" + source "https://gem.repo3" do gem "depends_on_rack" end G end it "installs from the other source and warns about ambiguous gems", :bundler => "< 3" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).to include("Warning: the gem 'rack' was found in multiple sources.") - expect(err).to include("Installed from: #{file_uri_for(gem_repo2)}") + expect(err).to include("Installed from: https://gem.repo2") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0") end it "fails", :bundler => "3" do - bundle :install, :raise_on_error => false + bundle :install, :artifice => "compact_index", :raise_on_error => false expect(err).to include("Each source after the first must include a block") expect(exitstatus).to eq(4) end @@ -267,16 +267,16 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo3)}" # contains depends_on_rack - source "#{file_uri_for(gem_repo2)}" # contains broken rack + source "https://gem.repo3" # contains depends_on_rack + source "https://gem.repo2" # contains broken rack gem "depends_on_rack" # installed from gem_repo3 - gem "rack", :source => "#{file_uri_for(gem_repo1)}" + gem "rack", :source => "https://gem.repo1" G end it "installs the dependency from the pinned source without warning", :bundler => "< 3" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0") @@ -284,14 +284,14 @@ RSpec.describe "bundle install with gems on multiple sources" do # In https://github.com/rubygems/bundler/issues/3585 this failed # when there is already a lock file, and the gems are missing, so try again system_gems [] - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0") end it "fails", :bundler => "3" do - bundle :install, :raise_on_error => false + bundle :install, :artifice => "compact_index", :raise_on_error => false expect(err).to include("Each source after the first must include a block") expect(exitstatus).to eq(4) end @@ -308,360 +308,457 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo2)}" + source "https://gem.repo2" gem "private_gem_1" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo3" do gem "private_gem_2" end G end it "fails" do - bundle :install, :raise_on_error => false - expect(err).to include("Could not find gem 'private_gem_1' in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.") + bundle :install, :artifice => "compact_index", :raise_on_error => false + expect(err).to include("Could not find gem 'private_gem_1' in rubygems repository https://gem.repo2/ or installed locally.") expect(err).to include("The source does not contain any versions of 'private_gem_1'") end end - context "when a top-level gem has an indirect dependency" do - context "when disable_multisource is set" do - before do - bundle "config set disable_multisource true" + context "when an indirect dependency can't be found in the aggregate rubygems source", :bundler => "< 3" do + before do + build_repo2 + + build_repo gem_repo3 do + build_gem "depends_on_missing", "1.0.1" do |s| + s.add_dependency "missing" + end end - before do - build_repo gem_repo2 do - build_gem "depends_on_rack", "1.0.1" do |s| - s.add_dependency "rack" - end + gemfile <<-G + source "https://gem.repo2" + + source "https://gem.repo3" + + gem "depends_on_missing" + G + end + + it "fails" do + bundle :install, :artifice => "compact_index", :raise_on_error => false + expect(err).to include("Could not find gem 'missing', which is required by gem 'depends_on_missing', in any of the sources.") + end + end + + context "when a top-level gem has an indirect dependency" do + before do + build_repo gem_repo2 do + build_gem "depends_on_rack", "1.0.1" do |s| + s.add_dependency "rack" end + end + + build_repo gem_repo3 do + build_gem "unrelated_gem", "1.0.0" + end - build_repo gem_repo3 do - build_gem "unrelated_gem", "1.0.0" + gemfile <<-G + source "https://gem.repo2" + + gem "depends_on_rack" + + source "https://gem.repo3" do + gem "unrelated_gem" end + G + end - gemfile <<-G - source "#{file_uri_for(gem_repo2)}" + context "and the dependency is only in the top-level source" do + before do + update_repo gem_repo2 do + build_gem "rack", "1.0.0" + end + end - gem "depends_on_rack" + it "installs the dependency from the top-level source without warning" do + bundle :install, :artifice => "compact_index" + expect(err).not_to include("Warning") + expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0") + expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote2") + expect(the_bundle).to include_gems("unrelated_gem 1.0.0", :source => "remote3") + end + end - source "#{file_uri_for(gem_repo3)}" do - gem "unrelated_gem" + context "and the dependency is only in a pinned source" do + before do + update_repo gem_repo3 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" end - G + end end - context "and the dependency is only in the top-level source" do - before do - update_repo gem_repo2 do - build_gem "rack", "1.0.0" - end + it "does not find the dependency" do + bundle :install, :artifice => "compact_index", :raise_on_error => false + expect(err).to include( + "Could not find gem 'rack', which is required by gem 'depends_on_rack', in rubygems repository https://gem.repo2/ or installed locally." + ) + end + end + + context "and the dependency is in both the top-level and a pinned source" do + before do + update_repo gem_repo2 do + build_gem "rack", "1.0.0" end - it "installs all gems without warning" do - bundle :install - expect(err).not_to include("Warning") - expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0") + update_repo gem_repo3 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end end end - context "and the dependency is only in a pinned source" do - before do - update_repo gem_repo3 do - build_gem "rack", "1.0.0" do |s| - s.write "lib/rack.rb", "RACK = 'FAIL'" - end - end + it "installs the dependency from the top-level source without warning" do + bundle :install, :artifice => "compact_index" + expect(err).not_to include("Warning") + expect(run("require 'rack'; puts RACK")).to eq("1.0.0") + expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0") + expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote2") + expect(the_bundle).to include_gems("unrelated_gem 1.0.0", :source => "remote3") + end + end + end + + context "when a scoped gem has a deeply nested indirect dependency" do + before do + build_repo gem_repo3 do + build_gem "depends_on_depends_on_rack", "1.0.1" do |s| + s.add_dependency "depends_on_rack" end - it "does not find the dependency" do - bundle :install, :raise_on_error => false - expect(err).to include("Could not find gem 'rack', which is required by gem 'depends_on_rack', in any of the relevant sources") + build_gem "depends_on_rack", "1.0.1" do |s| + s.add_dependency "rack" end end - context "and the dependency is in both the top-level and a pinned source" do - before do - update_repo gem_repo2 do - build_gem "rack", "1.0.0" - end + gemfile <<-G + source "https://gem.repo2" - update_repo gem_repo3 do - build_gem "rack", "1.0.0" do |s| - s.write "lib/rack.rb", "RACK = 'FAIL'" - end - end + source "https://gem.repo3" do + gem "depends_on_depends_on_rack" end + G + end - it "installs the dependency from the top-level source without warning" do - bundle :install - expect(err).not_to include("Warning") - expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0") + context "and the dependency is only in the top-level source" do + before do + update_repo gem_repo2 do + build_gem "rack", "1.0.0" end end + + it "installs the dependency from the top-level source" do + bundle :install, :artifice => "compact_index" + expect(the_bundle).to include_gems("depends_on_depends_on_rack 1.0.1", "depends_on_rack 1.0.1", "rack 1.0.0") + expect(the_bundle).to include_gems("rack 1.0.0", :source => "remote2") + expect(the_bundle).to include_gems("depends_on_depends_on_rack 1.0.1", "depends_on_rack 1.0.1", :source => "remote3") + end end - context "when the lockfile has aggregated rubygems sources and newer versions of dependencies are available" do + context "and the dependency is only in a pinned source" do before do - build_repo gem_repo2 do - build_gem "activesupport", "6.0.3.4" do |s| - s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" - s.add_dependency "i18n", ">= 0.7", "< 2" - s.add_dependency "minitest", "~> 5.1" - s.add_dependency "tzinfo", "~> 1.1" - s.add_dependency "zeitwerk", "~> 2.2", ">= 2.2.2" - end + build_repo2 - build_gem "activesupport", "6.1.2.1" do |s| - s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" - s.add_dependency "i18n", ">= 1.6", "< 2" - s.add_dependency "minitest", ">= 5.1" - s.add_dependency "tzinfo", "~> 2.0" - s.add_dependency "zeitwerk", "~> 2.3" - end + update_repo gem_repo3 do + build_gem "rack", "1.0.0" + end + end - build_gem "concurrent-ruby", "1.1.8" - build_gem "concurrent-ruby", "1.1.9" - build_gem "connection_pool", "2.2.3" + it "installs the dependency from the pinned source" do + bundle :install, :artifice => "compact_index" + expect(the_bundle).to include_gems("depends_on_depends_on_rack 1.0.1", "depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote3") + end + end - build_gem "i18n", "1.8.9" do |s| - s.add_dependency "concurrent-ruby", "~> 1.0" + context "and the dependency is in both the top-level and a pinned source" do + before do + update_repo gem_repo2 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" end + end - build_gem "minitest", "5.14.3" - build_gem "rack", "2.2.3" - build_gem "redis", "4.2.5" + update_repo gem_repo3 do + build_gem "rack", "1.0.0" + end + end - build_gem "sidekiq", "6.1.3" do |s| - s.add_dependency "connection_pool", ">= 2.2.2" - s.add_dependency "rack", "~> 2.0" - s.add_dependency "redis", ">= 4.2.0" - end + it "installs the dependency from the pinned source without warning" do + bundle :install, :artifice => "compact_index" + expect(the_bundle).to include_gems("depends_on_depends_on_rack 1.0.1", "depends_on_rack 1.0.1", "rack 1.0.0", :source => "remote3") + end + end + end - build_gem "thread_safe", "0.3.6" + context "when the lockfile has aggregated rubygems sources and newer versions of dependencies are available" do + before do + build_repo gem_repo2 do + build_gem "activesupport", "6.0.3.4" do |s| + s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" + s.add_dependency "i18n", ">= 0.7", "< 2" + s.add_dependency "minitest", "~> 5.1" + s.add_dependency "tzinfo", "~> 1.1" + s.add_dependency "zeitwerk", "~> 2.2", ">= 2.2.2" + end - build_gem "tzinfo", "1.2.9" do |s| - s.add_dependency "thread_safe", "~> 0.1" - end + build_gem "activesupport", "6.1.2.1" do |s| + s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" + s.add_dependency "i18n", ">= 1.6", "< 2" + s.add_dependency "minitest", ">= 5.1" + s.add_dependency "tzinfo", "~> 2.0" + s.add_dependency "zeitwerk", "~> 2.3" + end - build_gem "tzinfo", "2.0.4" do |s| - s.add_dependency "concurrent-ruby", "~> 1.0" - end + build_gem "concurrent-ruby", "1.1.8" + build_gem "concurrent-ruby", "1.1.9" + build_gem "connection_pool", "2.2.3" - build_gem "zeitwerk", "2.4.2" + build_gem "i18n", "1.8.9" do |s| + s.add_dependency "concurrent-ruby", "~> 1.0" end - build_repo gem_repo3 do - build_gem "sidekiq-pro", "5.2.1" do |s| - s.add_dependency "connection_pool", ">= 2.2.3" - s.add_dependency "sidekiq", ">= 6.1.0" - end + build_gem "minitest", "5.14.3" + build_gem "rack", "2.2.3" + build_gem "redis", "4.2.5" + + build_gem "sidekiq", "6.1.3" do |s| + s.add_dependency "connection_pool", ">= 2.2.2" + s.add_dependency "rack", "~> 2.0" + s.add_dependency "redis", ">= 4.2.0" end - gemfile <<-G - # frozen_string_literal: true + build_gem "thread_safe", "0.3.6" - source "#{file_uri_for(gem_repo2)}" + build_gem "tzinfo", "1.2.9" do |s| + s.add_dependency "thread_safe", "~> 0.1" + end - gem "activesupport" + build_gem "tzinfo", "2.0.4" do |s| + s.add_dependency "concurrent-ruby", "~> 1.0" + end - source "#{file_uri_for(gem_repo3)}" do - gem "sidekiq-pro" - end - G + build_gem "zeitwerk", "2.4.2" + end - lockfile <<~L - GEM - remote: #{file_uri_for(gem_repo2)}/ - remote: #{file_uri_for(gem_repo3)}/ - specs: - activesupport (6.0.3.4) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - concurrent-ruby (1.1.8) - connection_pool (2.2.3) - i18n (1.8.9) - concurrent-ruby (~> 1.0) - minitest (5.14.3) - rack (2.2.3) - redis (4.2.5) - sidekiq (6.1.3) - connection_pool (>= 2.2.2) - rack (~> 2.0) - redis (>= 4.2.0) - sidekiq-pro (5.2.1) - connection_pool (>= 2.2.3) - sidekiq (>= 6.1.0) - thread_safe (0.3.6) - tzinfo (1.2.9) - thread_safe (~> 0.1) - zeitwerk (2.4.2) - - PLATFORMS - #{specific_local_platform} - - DEPENDENCIES - activesupport - sidekiq-pro! - - BUNDLED WITH - #{Bundler::VERSION} - L + build_repo gem_repo3 do + build_gem "sidekiq-pro", "5.2.1" do |s| + s.add_dependency "connection_pool", ">= 2.2.3" + s.add_dependency "sidekiq", ">= 6.1.0" + end end - it "does not install newer versions or generate lockfile changes when running bundle install, and warns", :bundler => "< 3" do - initial_lockfile = lockfile + gemfile <<-G + # frozen_string_literal: true - bundle :install + source "https://gem.repo2" - expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + gem "activesupport" - expect(the_bundle).to include_gems("activesupport 6.0.3.4") - expect(the_bundle).not_to include_gems("activesupport 6.1.2.1") - expect(the_bundle).to include_gems("tzinfo 1.2.9") - expect(the_bundle).not_to include_gems("tzinfo 2.0.4") - expect(the_bundle).to include_gems("concurrent-ruby 1.1.8") - expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.9") + source "https://gem.repo3" do + gem "sidekiq-pro" + end + G - expect(lockfile).to eq(initial_lockfile) - end + lockfile <<~L + GEM + remote: https://gem.repo2/ + remote: https://gem.repo3/ + specs: + activesupport (6.0.3.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) + concurrent-ruby (1.1.8) + connection_pool (2.2.3) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + minitest (5.14.3) + rack (2.2.3) + redis (4.2.5) + sidekiq (6.1.3) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) + sidekiq-pro (5.2.1) + connection_pool (>= 2.2.3) + sidekiq (>= 6.1.0) + thread_safe (0.3.6) + tzinfo (1.2.9) + thread_safe (~> 0.1) + zeitwerk (2.4.2) - it "fails when running bundle install", :bundler => "3" do - initial_lockfile = lockfile + PLATFORMS + #{specific_local_platform} - bundle :install, :raise_on_error => false + DEPENDENCIES + activesupport + sidekiq-pro! - expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + BUNDLED WITH + #{Bundler::VERSION} + L + end - expect(lockfile).to eq(initial_lockfile) - end + it "does not install newer versions or generate lockfile changes when running bundle install, and warns", :bundler => "< 3" do + initial_lockfile = lockfile - it "splits sections and upgrades gems when running bundle update, and doesn't warn" do - bundle "update --all" - expect(err).to be_empty - - expect(the_bundle).not_to include_gems("activesupport 6.0.3.4") - expect(the_bundle).to include_gems("activesupport 6.1.2.1") - expect(the_bundle).not_to include_gems("tzinfo 1.2.9") - expect(the_bundle).to include_gems("tzinfo 2.0.4") - expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.8") - expect(the_bundle).to include_gems("concurrent-ruby 1.1.9") - - expect(lockfile).to eq <<~L - GEM - remote: #{file_uri_for(gem_repo2)}/ - specs: - activesupport (6.1.2.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - concurrent-ruby (1.1.9) - connection_pool (2.2.3) - i18n (1.8.9) - concurrent-ruby (~> 1.0) - minitest (5.14.3) - rack (2.2.3) - redis (4.2.5) - sidekiq (6.1.3) - connection_pool (>= 2.2.2) - rack (~> 2.0) - redis (>= 4.2.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) - zeitwerk (2.4.2) - - GEM - remote: #{file_uri_for(gem_repo3)}/ - specs: - sidekiq-pro (5.2.1) - connection_pool (>= 2.2.3) - sidekiq (>= 6.1.0) - - PLATFORMS - #{specific_local_platform} - - DEPENDENCIES - activesupport - sidekiq-pro! - - BUNDLED WITH - #{Bundler::VERSION} - L - end + bundle :install, :artifice => "compact_index" - it "it keeps the current lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do - bundle "update concurrent-ruby" - expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") - - expect(the_bundle).to include_gems("activesupport 6.0.3.4") - expect(the_bundle).not_to include_gems("activesupport 6.1.2.1") - expect(the_bundle).to include_gems("tzinfo 1.2.9") - expect(the_bundle).not_to include_gems("tzinfo 2.0.4") - expect(the_bundle).to include_gems("concurrent-ruby 1.1.9") - expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.8") - - expect(lockfile).to eq <<~L - GEM - remote: #{file_uri_for(gem_repo2)}/ - remote: #{file_uri_for(gem_repo3)}/ - specs: - activesupport (6.0.3.4) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - concurrent-ruby (1.1.9) - connection_pool (2.2.3) - i18n (1.8.9) - concurrent-ruby (~> 1.0) - minitest (5.14.3) - rack (2.2.3) - redis (4.2.5) - sidekiq (6.1.3) - connection_pool (>= 2.2.2) - rack (~> 2.0) - redis (>= 4.2.0) - sidekiq-pro (5.2.1) - connection_pool (>= 2.2.3) - sidekiq (>= 6.1.0) - thread_safe (0.3.6) - tzinfo (1.2.9) - thread_safe (~> 0.1) - zeitwerk (2.4.2) - - PLATFORMS - #{specific_local_platform} - - DEPENDENCIES - activesupport - sidekiq-pro! - - BUNDLED WITH - #{Bundler::VERSION} - L - end + expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") - it "fails when running bundle update with an argument", :bundler => "3" do - initial_lockfile = lockfile + expect(the_bundle).to include_gems("activesupport 6.0.3.4") + expect(the_bundle).not_to include_gems("activesupport 6.1.2.1") + expect(the_bundle).to include_gems("tzinfo 1.2.9") + expect(the_bundle).not_to include_gems("tzinfo 2.0.4") + expect(the_bundle).to include_gems("concurrent-ruby 1.1.8") + expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.9") - bundle "update concurrent-ruby", :raise_on_error => false + expect(lockfile).to eq(initial_lockfile) + end - expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + it "fails when running bundle install", :bundler => "3" do + initial_lockfile = lockfile - expect(lockfile).to eq(initial_lockfile) - end + bundle :install, :artifice => "compact_index", :raise_on_error => false + + expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + + expect(lockfile).to eq(initial_lockfile) + end + + it "splits sections and upgrades gems when running bundle update, and doesn't warn" do + bundle "update --all", :artifice => "compact_index" + expect(err).to be_empty + + expect(the_bundle).not_to include_gems("activesupport 6.0.3.4") + expect(the_bundle).to include_gems("activesupport 6.1.2.1") + expect(the_bundle).not_to include_gems("tzinfo 1.2.9") + expect(the_bundle).to include_gems("tzinfo 2.0.4") + expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.8") + expect(the_bundle).to include_gems("concurrent-ruby 1.1.9") + + expect(lockfile).to eq <<~L + GEM + remote: https://gem.repo2/ + specs: + activesupport (6.1.2.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + concurrent-ruby (1.1.9) + connection_pool (2.2.3) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + minitest (5.14.3) + rack (2.2.3) + redis (4.2.5) + sidekiq (6.1.3) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) + + GEM + remote: https://gem.repo3/ + specs: + sidekiq-pro (5.2.1) + connection_pool (>= 2.2.3) + sidekiq (>= 6.1.0) + + PLATFORMS + #{specific_local_platform} + + DEPENDENCIES + activesupport + sidekiq-pro! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "it keeps the current lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do + bundle "update concurrent-ruby", :artifice => "compact_index" + expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + + expect(the_bundle).to include_gems("activesupport 6.0.3.4") + expect(the_bundle).not_to include_gems("activesupport 6.1.2.1") + expect(the_bundle).to include_gems("tzinfo 1.2.9") + expect(the_bundle).not_to include_gems("tzinfo 2.0.4") + expect(the_bundle).to include_gems("concurrent-ruby 1.1.9") + expect(the_bundle).not_to include_gems("concurrent-ruby 1.1.8") + + expect(lockfile).to eq <<~L + GEM + remote: https://gem.repo2/ + remote: https://gem.repo3/ + specs: + activesupport (6.0.3.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) + concurrent-ruby (1.1.9) + connection_pool (2.2.3) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + minitest (5.14.3) + rack (2.2.3) + redis (4.2.5) + sidekiq (6.1.3) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) + sidekiq-pro (5.2.1) + connection_pool (>= 2.2.3) + sidekiq (>= 6.1.0) + thread_safe (0.3.6) + tzinfo (1.2.9) + thread_safe (~> 0.1) + zeitwerk (2.4.2) + + PLATFORMS + #{specific_local_platform} + + DEPENDENCIES + activesupport + sidekiq-pro! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "fails when running bundle update with an argument", :bundler => "3" do + initial_lockfile = lockfile + + bundle "update concurrent-ruby", :artifice => "compact_index", :raise_on_error => false + + expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") + + expect(lockfile).to eq(initial_lockfile) end end - context "when a top-level gem has an indirect dependency present in the default source, but with a different version from the one resolved", :bundler => "< 3" do + context "when a top-level gem has an indirect dependency present in the default source, but with a different version from the one resolved" do before do build_lib "activesupport", "7.0.0.alpha", :path => lib_path("rails/activesupport") build_lib "rails", "7.0.0.alpha", :path => lib_path("rails") do |s| @@ -677,7 +774,7 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo2)}" + source "https://gem.repo2" gemspec :path => "#{lib_path("rails")}" @@ -686,7 +783,7 @@ RSpec.describe "bundle install with gems on multiple sources" do end it "installs all gems without warning" do - bundle :install + bundle :install, :artifice => "compact_index" expect(err).not_to include("Warning") expect(the_bundle).to include_gems("activesupport 7.0.0.alpha", "rails 7.0.0.alpha") expect(the_bundle).to include_gems("activesupport 7.0.0.alpha", :source => "path@#{lib_path("rails/activesupport")}") @@ -711,9 +808,9 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo2)}" + source "https://gem.repo2" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo3" do gem "handsoap" end @@ -724,14 +821,14 @@ RSpec.describe "bundle install with gems on multiple sources" do it "installs from the default source without any warnings or errors and generates a proper lockfile" do expected_lockfile = <<~L GEM - remote: #{file_uri_for(gem_repo2)}/ + remote: https://gem.repo2/ specs: nokogiri (1.11.1) racca (~> 1.4) racca (1.5.2) GEM - remote: #{file_uri_for(gem_repo3)}/ + remote: https://gem.repo3/ specs: handsoap (0.2.5.5) nokogiri (>= 1.2.3) @@ -747,7 +844,7 @@ RSpec.describe "bundle install with gems on multiple sources" do #{Bundler::VERSION} L - bundle "install --verbose" + bundle "install --verbose", :artifice => "compact_index" expect(err).not_to include("Warning") expect(the_bundle).to include_gems("handsoap 0.2.5.5", "nokogiri 1.11.1", "racca 1.5.2") expect(the_bundle).to include_gems("handsoap 0.2.5.5", :source => "remote3") @@ -756,7 +853,7 @@ RSpec.describe "bundle install with gems on multiple sources" do # Even if the gems are already installed FileUtils.rm bundled_app_lock - bundle "install --verbose" + bundle "install --verbose", :artifice => "compact_index" expect(err).not_to include("Warning") expect(the_bundle).to include_gems("handsoap 0.2.5.5", "nokogiri 1.11.1", "racca 1.5.2") expect(the_bundle).to include_gems("handsoap 0.2.5.5", :source => "remote3") @@ -771,9 +868,9 @@ RSpec.describe "bundle install with gems on multiple sources" do build_gem "not_in_repo1", "1.0.0" end - install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo3)}" - gem "not_in_repo1", :source => "#{file_uri_for(gem_repo1)}" + install_gemfile <<-G, :artifice => "compact_index", :raise_on_error => false + source "https://gem.repo3" + gem "not_in_repo1", :source => "https://gem.repo1" G end @@ -788,11 +885,11 @@ RSpec.describe "bundle install with gems on multiple sources" do lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)} + remote: https://gem.repo1 specs: GEM - remote: #{file_uri_for(gem_repo3)} + remote: https://gem.repo3 specs: rack (0.9.1) @@ -804,8 +901,8 @@ RSpec.describe "bundle install with gems on multiple sources" do L gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo1" + source "https://gem.repo3" do gem 'rack' end G @@ -821,8 +918,8 @@ RSpec.describe "bundle install with gems on multiple sources" do let(:aggregate_gem_section_lockfile) do <<~L GEM - remote: #{file_uri_for(gem_repo1)}/ - remote: #{file_uri_for(gem_repo3)}/ + remote: https://gem.repo1/ + remote: https://gem.repo3/ specs: rack (0.9.1) @@ -840,11 +937,11 @@ RSpec.describe "bundle install with gems on multiple sources" do let(:split_gem_section_lockfile) do <<~L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: https://gem.repo1/ specs: GEM - remote: #{file_uri_for(gem_repo3)}/ + remote: https://gem.repo3/ specs: rack (0.9.1) @@ -865,8 +962,8 @@ RSpec.describe "bundle install with gems on multiple sources" do end gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo1" + source "https://gem.repo3" do gem 'rack' end G @@ -877,7 +974,7 @@ RSpec.describe "bundle install with gems on multiple sources" do it "installs the existing lockfile but prints a warning", :bundler => "< 3" do bundle "config set --local deployment true" - bundle "install" + bundle "install", :artifice => "compact_index" expect(lockfile).to eq(aggregate_gem_section_lockfile) expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") @@ -887,7 +984,7 @@ RSpec.describe "bundle install with gems on multiple sources" do it "refuses to install the existing lockfile and prints an error", :bundler => "3" do bundle "config set --local deployment true" - bundle "install", :raise_on_error =>false + bundle "install", :artifice => "compact_index", :raise_on_error =>false expect(lockfile).to eq(aggregate_gem_section_lockfile) expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.") @@ -900,13 +997,13 @@ RSpec.describe "bundle install with gems on multiple sources" do build_lib "foo" gemfile <<-G - gem "rack", :source => "#{file_uri_for(gem_repo1)}" + gem "rack", :source => "https://gem.repo1" gem "foo", :path => "#{lib_path("foo-1.0")}" G end it "does not unlock the non-path gem after install" do - bundle :install + bundle :install, :artifice => "compact_index" bundle %(exec ruby -e 'puts "OK"') @@ -919,8 +1016,8 @@ RSpec.describe "bundle install with gems on multiple sources" do before do system_gems "rack-0.9.1" - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo1" gem "rack" # should come from repo1! G end @@ -941,14 +1038,14 @@ RSpec.describe "bundle install with gems on multiple sources" do # Installing this gemfile... gemfile <<-G - source '#{file_uri_for(gem_repo1)}' + source 'https://gem.repo1' gem 'rack' - gem 'foo', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}' - gem 'bar', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}' + gem 'foo', '~> 0.1', :source => 'https://gem.repo4' + gem 'bar', '~> 0.1', :source => 'https://gem.repo4' G - bundle "config --local path ../gems/system" - bundle :install + bundle "config set --local path ../gems/system" + bundle :install, :artifice => "compact_index" # And then we add some new versions... update_repo4 do @@ -959,11 +1056,11 @@ RSpec.describe "bundle install with gems on multiple sources" do it "allows them to be unlocked separately" do # And install this gemfile, updating only foo. - install_gemfile <<-G - source '#{file_uri_for(gem_repo1)}' + install_gemfile <<-G, :artifice => "compact_index" + source 'https://gem.repo1' gem 'rack' - gem 'foo', '~> 0.2', :source => '#{file_uri_for(gem_repo4)}' - gem 'bar', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}' + gem 'foo', '~> 0.2', :source => 'https://gem.repo4' + gem 'bar', '~> 0.1', :source => 'https://gem.repo4' G # It should update foo to 0.2, but not the (locked) bar 0.1 @@ -983,11 +1080,11 @@ RSpec.describe "bundle install with gems on multiple sources" do build_git "git1" build_git "git2" - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo1" gem "rails" - source "#{file_uri_for(gem_repo3)}" do + source "https://gem.repo3" do gem "rack" end @@ -999,7 +1096,7 @@ RSpec.describe "bundle install with gems on multiple sources" do end it "does not re-resolve" do - bundle :install, :verbose => true + bundle :install, :artifice => "compact_index", :verbose => true expect(out).to include("using resolution from the lockfile") expect(out).not_to include("re-resolving dependencies") end @@ -1008,27 +1105,24 @@ RSpec.describe "bundle install with gems on multiple sources" do context "when a gem is installed to system gems" do before do - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo1" gem "rack" G end context "and the gemfile changes" do it "is still able to find that gem from remote sources" do - source_uri = file_uri_for(gem_repo1) - second_uri = file_uri_for(gem_repo4) - build_repo4 do build_gem "rack", "2.0.1.1.forked" build_gem "thor", "0.19.1.1.forked" end # When this gemfile is installed... - install_gemfile <<-G - source "#{source_uri}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo1" - source "#{second_uri}" do + source "https://gem.repo4" do gem "rack", "2.0.1.1.forked" gem "thor" end @@ -1037,9 +1131,9 @@ RSpec.describe "bundle install with gems on multiple sources" do # Then we change the Gemfile by adding a version to thor gemfile <<-G - source "#{source_uri}" + source "https://gem.repo1" - source "#{second_uri}" do + source "https://gem.repo4" do gem "rack", "2.0.1.1.forked" gem "thor", "0.19.1.1.forked" end @@ -1047,15 +1141,15 @@ RSpec.describe "bundle install with gems on multiple sources" do G # But we should still be able to find rack 2.0.1.1.forked and install it - bundle :install + bundle :install, :artifice => "compact_index" end end end describe "source changed to one containing a higher version of a dependency" do before do - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo1" gem "rack" G @@ -1072,8 +1166,8 @@ RSpec.describe "bundle install with gems on multiple sources" do s.add_dependency "bar", "=1.0.0" end - install_gemfile <<-G - source "#{file_uri_for(gem_repo2)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo2" gem "rack" gemspec :path => "#{tmp.join("gemspec_test")}" G @@ -1093,10 +1187,10 @@ RSpec.describe "bundle install with gems on multiple sources" do build_gem "example", "1.0.2" end - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" + install_gemfile <<-G, :artifice => "compact_index" + source "https://gem.repo4" - gem "example", :source => "#{file_uri_for(gem_repo2)}" + gem "example", :source => "https://gem.repo2" G bundle "info example" @@ -1104,12 +1198,41 @@ RSpec.describe "bundle install with gems on multiple sources" do system_gems "example-1.0.2", :path => default_bundle_path, :gem_repo => gem_repo4 - bundle "update example --verbose" + bundle "update example --verbose", :artifice => "compact_index" expect(out).not_to include("Using example 1.0.2") expect(out).to include("Using example 0.1.0") end - context "when a gem is available from multiple ambiguous sources", :bundler => "3" do + context "when an indirect dependency is available from multiple ambiguous sources", :bundler => "< 3" do + it "succeeds but warns, suggesting a source block" do + build_repo4 do + build_gem "depends_on_rack" do |s| + s.add_dependency "rack" + end + build_gem "rack" + end + + install_gemfile <<-G, :artifice => "compact_index", :raise_on_error => false + source "https://gem.repo4" do + gem "depends_on_rack" + end + + source "https://gem.repo1" do + gem "thin" + end + G + expect(err).to eq strip_whitespace(<<-EOS).strip + Warning: The gem 'rack' was found in multiple relevant sources. + * rubygems repository https://gem.repo1/ or installed locally + * rubygems repository https://gem.repo4/ or installed locally + You should add this gem to the source block for the source you wish it to be installed from. + EOS + expect(last_command).to be_success + expect(the_bundle).to be_locked + end + end + + context "when an indirect dependency is available from multiple ambiguous sources", :bundler => "3" do it "raises, suggesting a source block" do build_repo4 do build_gem "depends_on_rack" do |s| @@ -1118,18 +1241,19 @@ RSpec.describe "bundle install with gems on multiple sources" do build_gem "rack" end - install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo4)}" - source "#{file_uri_for(gem_repo1)}" do + install_gemfile <<-G, :artifice => "compact_index", :raise_on_error => false + source "https://gem.repo4" do + gem "depends_on_rack" + end + source "https://gem.repo1" do gem "thin" end - gem "depends_on_rack" G expect(last_command).to be_failure expect(err).to eq strip_whitespace(<<-EOS).strip The gem 'rack' was found in multiple relevant sources. - * rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally - * rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally + * rubygems repository https://gem.repo1/ or installed locally + * rubygems repository https://gem.repo4/ or installed locally You must add this gem to the source block for the source you wish it to be installed from. EOS expect(the_bundle).not_to be_locked diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index a5b78443b9..c6e526a95e 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -141,10 +141,10 @@ RSpec.describe "bundle install with specific platforms" do 2.1.4 L - bundle "install --verbose", :artifice => :compact_index, :env => { "BUNDLER_VERSION" => "2.1.4", "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } + bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_VERSION" => "2.1.4", "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Installing libv8 8.4.255.0 (universal-darwin)") - bundle "add mini_racer --verbose", :artifice => :compact_index, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } + bundle "add mini_racer --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Using libv8 8.4.255.0 (universal-darwin)") end diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index 5e2b0267ae..8be97ed5d2 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -80,8 +80,8 @@ RSpec.describe "compact index api" do G bundle :install, :artifice => "compact_index" - bundle "config --local deployment true" - bundle "config --local path vendor/bundle" + bundle "config set --local deployment true" + bundle "config set --local path vendor/bundle" bundle :install, :artifice => "compact_index" expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" @@ -118,7 +118,7 @@ RSpec.describe "compact index api" do bundle :install, :artifice => "compact_index" - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "compact_index" expect(the_bundle).to include_gems("rails 2.3.2") @@ -132,7 +132,7 @@ RSpec.describe "compact index api" do G bundle "install", :artifice => "compact_index" - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "compact_index" expect(the_bundle).to include_gems("foo 1.0") @@ -366,31 +366,6 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "activesupport 1.2.3" end - it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 3" do - # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that - # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 - # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other - # repo and installs it. - build_repo4 do - build_gem "activesupport", "1.2.0" - build_gem "somegem", "1.0.0" do |s| - s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1 - end - end - - gemfile <<-G - source "#{source_uri}" - source "#{source_uri}/extra" do - gem 'somegem', '1.0.0' - end - G - - bundle :install, :artifice => "compact_index_extra_api" - - expect(the_bundle).to include_gems "somegem 1.0.0" - expect(the_bundle).to include_gems "activesupport 1.2.3" - end - it "prints API output properly with back deps" do build_repo2 do build_gem "back_deps" do |s| @@ -467,7 +442,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do + it "fetches again when more dependencies are found in subsequent sources using deployment mode", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -482,8 +457,8 @@ The checksum of /versions does not match the checksum provided by the server! So G bundle :install, :artifice => "compact_index_extra" - - bundle "install --deployment", :artifice => "compact_index_extra" + bundle "config --set local deployment true" + bundle :install, :artifice => "compact_index_extra" expect(the_bundle).to include_gems "back_deps 1.0" end @@ -503,7 +478,7 @@ The checksum of /versions does not match the checksum provided by the server! So G bundle :install, :artifice => "compact_index_extra" - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "compact_index_extra" expect(the_bundle).to include_gems "back_deps 1.0" end diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index 0b6e6f0368..eae8daa682 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -60,8 +60,8 @@ RSpec.describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint" - bundle "config --local deployment true" - bundle "config --local path vendor/bundle" + bundle "config set --local deployment true" + bundle "config set --local path vendor/bundle" bundle :install, :artifice => "endpoint" expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" @@ -98,7 +98,7 @@ RSpec.describe "gemcutter's dependency API" do bundle :install, :artifice => "endpoint" - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "endpoint" expect(the_bundle).to include_gems("rails 2.3.2") @@ -112,7 +112,7 @@ RSpec.describe "gemcutter's dependency API" do G bundle "install", :artifice => "endpoint" - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle :install, :artifice => "endpoint" expect(the_bundle).to include_gems("foo 1.0") @@ -338,31 +338,6 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "activesupport 1.2.3" end - it "considers all possible versions of dependencies from all api gem sources using blocks" do - # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that - # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 - # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other - # repo and installs it. - build_repo4 do - build_gem "activesupport", "1.2.0" - build_gem "somegem", "1.0.0" do |s| - s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1 - end - end - - gemfile <<-G - source "#{source_uri}" - source "#{source_uri}/extra" do - gem 'somegem', '1.0.0' - end - G - - bundle :install, :artifice => "endpoint_extra_api" - - expect(the_bundle).to include_gems "somegem 1.0.0" - expect(the_bundle).to include_gems "activesupport 1.2.3" - end - it "prints API output properly with back deps" do build_repo2 do build_gem "back_deps" do |s| @@ -438,7 +413,7 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do + it "fetches again when more dependencies are found in subsequent sources using deployment mode", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -453,8 +428,8 @@ RSpec.describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint_extra" - - bundle "install --deployment", :artifice => "endpoint_extra" + bundle "config set --local deployment true" + bundle :install, :artifice => "endpoint_extra" expect(the_bundle).to include_gems "back_deps 1.0" end @@ -474,8 +449,7 @@ RSpec.describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint_extra" - - bundle "config --local deployment true" + bundle "config set --local deployment true" bundle "install", :artifice => "endpoint_extra" expect(the_bundle).to include_gems "back_deps 1.0" end diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index 0a0f992704..08d5276a54 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -94,7 +94,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{file_uri_for(gem_repo1)}" gem "rails" G - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :dir => cwd end @@ -110,7 +110,7 @@ RSpec.shared_examples "bundle install --standalone" do describe "with gems with native extension", :ruby_repo do before do - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" install_gemfile <<-G, :standalone => true, :dir => cwd source "#{file_uri_for(gem_repo1)}" gem "very_simple_binary" @@ -144,7 +144,7 @@ RSpec.shared_examples "bundle install --standalone" do end G end - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" install_gemfile <<-G, :standalone => true, :dir => cwd, :raise_on_error => false gem "bar", :git => "#{lib_path("bar-1.0")}" G @@ -165,7 +165,7 @@ RSpec.shared_examples "bundle install --standalone" do gem "rails" gem "devise", :git => "#{lib_path("devise-1.0")}" G - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :dir => cwd end @@ -193,7 +193,7 @@ RSpec.shared_examples "bundle install --standalone" do gem "rack-test" end G - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :dir => cwd end @@ -207,7 +207,7 @@ RSpec.shared_examples "bundle install --standalone" do include_examples "common functionality" it "allows creating a standalone file with limited groups" do - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => "default", :dir => cwd load_error_ruby <<-RUBY, "spec" @@ -224,8 +224,8 @@ RSpec.shared_examples "bundle install --standalone" do end it "allows `without` configuration to limit the groups used in a standalone" do - bundle "config --local path #{bundled_app("bundle")}" - bundle "config --local without test" + bundle "config set --local path #{bundled_app("bundle")}" + bundle "config set --local without test" bundle :install, :standalone => true, :dir => cwd load_error_ruby <<-RUBY, "spec" @@ -242,7 +242,7 @@ RSpec.shared_examples "bundle install --standalone" do end it "allows `path` configuration to change the location of the standalone bundle" do - bundle "config --local path path/to/bundle" + bundle "config set --local path path/to/bundle" bundle "install", :standalone => true, :dir => cwd ruby <<-RUBY @@ -257,9 +257,9 @@ RSpec.shared_examples "bundle install --standalone" do end it "allows `without` to limit the groups used in a standalone" do - bundle "config --local without test" + bundle "config set --local without test" bundle :install, :dir => cwd - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :dir => cwd load_error_ruby <<-RUBY, "spec" @@ -285,7 +285,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{source_uri}" gem "rails" G - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :artifice => "endpoint", :dir => cwd end @@ -306,7 +306,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{file_uri_for(gem_repo1)}" gem "rails" G - bundle "config --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" bundle :install, :standalone => true, :binstubs => true, :dir => cwd end diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb index 484959dc2a..4a3827eafd 100644 --- a/spec/bundler/install/git_spec.rb +++ b/spec/bundler/install/git_spec.rb @@ -68,8 +68,8 @@ RSpec.describe "bundle install" do foo! L - bundle "config --local path vendor/bundle" - bundle "config --local without development" + bundle "config set --local path vendor/bundle" + bundle "config set --local without development" bundle :install expect(out).to include("Bundle complete!") diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb index a05467db12..b0392c4ed2 100644 --- a/spec/bundler/install/path_spec.rb +++ b/spec/bundler/install/path_spec.rb @@ -14,14 +14,14 @@ RSpec.describe "bundle install" do end it "does not use available system gems with `vendor/bundle" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install expect(the_bundle).to include_gems "rack 1.0.0" end it "uses system gems with `path.system` configured with more priority than `path`" do - bundle "config --local path.system true" - bundle "config --global path vendor/bundle" + bundle "config set --local path.system true" + bundle "config set --global path vendor/bundle" bundle :install run "require 'rack'", :raise_on_error => false expect(out).to include("FAIL") @@ -31,7 +31,7 @@ RSpec.describe "bundle install" do dir = bundled_app("bun++dle") dir.mkpath - bundle "config --local path #{dir.join("vendor/bundle")}" + bundle "config set --local path #{dir.join("vendor/bundle")}" bundle :install, :dir => dir expect(out).to include("installed into `./vendor/bundle`") @@ -39,7 +39,7 @@ RSpec.describe "bundle install" do end it "prints a message to let the user know where gems where installed" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install expect(out).to include("gems are installed into `./vendor/bundle`") end @@ -109,7 +109,7 @@ RSpec.describe "bundle install" do context "when set via #{type}" do it "installs gems to a path if one is specified" do set_bundle_path(type, bundled_app("vendor2").to_s) - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install expect(vendored_gems("gems/rack-1.0.0")).to be_directory @@ -159,7 +159,7 @@ RSpec.describe "bundle install" do end it "sets BUNDLE_PATH as the first argument to bundle install" do - bundle "config --local path ./vendor/bundle" + bundle "config set --local path ./vendor/bundle" bundle :install expect(vendored_gems("gems/rack-1.0.0")).to be_directory @@ -169,7 +169,7 @@ RSpec.describe "bundle install" do it "disables system gems when passing a path to install" do # This is so that vendored gems can be distributed to others build_gem "rack", "1.1.0", :to_system => true - bundle "config --local path ./vendor/bundle" + bundle "config set --local path ./vendor/bundle" bundle :install expect(vendored_gems("gems/rack-1.0.0")).to be_directory @@ -186,7 +186,7 @@ RSpec.describe "bundle install" do gem "very_simple_binary" G - bundle "config --local path ./vendor/bundle" + bundle "config set --local path ./vendor/bundle" bundle :install expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory @@ -198,7 +198,7 @@ RSpec.describe "bundle install" do run "require 'very_simple_binary_c'", :raise_on_error => false expect(err).to include("Bundler::GemNotFound") - bundle "config --local path ./vendor/bundle" + bundle "config set --local path ./vendor/bundle" bundle :install expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory @@ -218,7 +218,7 @@ RSpec.describe "bundle install" do gem "rack" G - bundle "config --local path bundle" + bundle "config set --local path bundle" bundle :install, :raise_on_error => false expect(err).to include("file already exists") end diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 7ef85ecf13..0fbe9ee80d 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -1193,7 +1193,7 @@ RSpec.describe "the lockfile format" do gem "omg", :git => "#{lib_path("omg")}", :branch => 'master' G - bundle "config --local path vendor" + bundle "config set --local path vendor" bundle :install expect(the_bundle).to include_gems "omg 1.0" @@ -1347,7 +1347,7 @@ RSpec.describe "the lockfile format" do expect do ruby <<-RUBY - require '#{lib_dir}/bundler' + require '#{entrypoint}' Bundler.setup RUBY end.not_to change { File.mtime(bundled_app_lock) } diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index 7dbb80af80..41d8ef56bc 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -439,7 +439,7 @@ RSpec.describe "major deprecations" do G ruby <<-RUBY - require '#{lib_dir}/bundler' + require '#{entrypoint}' Bundler.setup Bundler.setup @@ -547,18 +547,6 @@ The :gist git source is deprecated, and will be removed in the future. Add this G end - context "without flags" do - before do - bundle :show - end - - it "prints a deprecation warning recommending `bundle list`", :bundler => "< 3" do - expect(deprecations).to include("use `bundle list` instead of `bundle show`") - end - - pending "fails with a helpful message", :bundler => "3" - end - context "with --outdated flag" do before do bundle "show --outdated" @@ -570,54 +558,6 @@ The :gist git source is deprecated, and will be removed in the future. Add this pending "fails with a helpful message", :bundler => "3" end - - context "with --verbose flag" do - before do - bundle "show --verbose" - end - - it "prints a deprecation warning informing about its removal", :bundler => "< 3" do - expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement") - end - - pending "fails with a helpful message", :bundler => "3" - end - - context "with a gem argument" do - before do - bundle "show rack" - end - - it "prints a deprecation warning recommending `bundle info`", :bundler => "< 3" do - expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`") - end - - pending "fails with a helpful message", :bundler => "3" - end - - context "with the --paths option" do - before do - bundle "show --paths" - end - - it "prints a deprecation warning recommending `bundle list`", :bundler => "< 3" do - expect(deprecations).to include("use `bundle list` instead of `bundle show --paths`") - end - - pending "fails with a helpful message", :bundler => "3" - end - - context "with a gem argument and the --paths option" do - before do - bundle "show rack --paths" - end - - it "prints deprecation warning recommending `bundle info`", :bundler => "< 3" do - expect(deprecations).to include("use `bundle info rack --path` instead of `bundle show rack --paths`") - end - - pending "fails with a helpful message", :bundler => "3" - end end context "bundle console" do diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index 370973ad1a..308f9c79fc 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -228,7 +228,7 @@ RSpec.describe "bundler plugin install" do gem 'rack', "1.0.0" G - bundle "config --local deployment true" + bundle "config set --local deployment true" install_gemfile <<-G source '#{file_uri_for(gem_repo2)}' plugin 'foo' diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index 03a377ac93..e2bab9c199 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -132,7 +132,7 @@ RSpec.describe "real source plugins" do end it "copies repository to vendor cache and uses it even when installed with `path` configured" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install bundle "config set cache_all true" bundle :cache @@ -144,7 +144,7 @@ RSpec.describe "real source plugins" do end it "bundler package copies repository to vendor cache" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install bundle "config set cache_all true" bundle :cache diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 54dfd10447..524870ca9e 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -224,7 +224,7 @@ RSpec.describe "The library itself" do end it "ships the correct set of files" do - git_list = git_ls_files(ruby_core? ? "lib/bundler lib/bundler.rb man/bundle* man/gemfile* libexec/bundle*" : "lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec") + git_list = git_ls_files(ruby_core? ? "lib/bundler lib/bundler.rb libexec/bundle*" : "lib exe CHANGELOG.md LICENSE.md README.md bundler.gemspec") gem_list = loaded_gemspec.files diff --git a/spec/bundler/realworld/double_check_spec.rb b/spec/bundler/realworld/double_check_spec.rb index 07697f080e..d7f28d10bb 100644 --- a/spec/bundler/realworld/double_check_spec.rb +++ b/spec/bundler/realworld/double_check_spec.rb @@ -25,9 +25,9 @@ RSpec.describe "double checking sources", :realworld => true do RUBY cmd = <<-RUBY - require "#{lib_dir}/bundler" + require "#{entrypoint}" require "#{spec_dir}/support/artifice/vcr" - require "#{lib_dir}/bundler/inline" + require "#{entrypoint}/inline" gemfile(true) do source "https://rubygems.org" gem "rails", path: "." diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index 1925f76c06..0fac56c942 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -4,9 +4,9 @@ RSpec.describe "real world edgecases", :realworld => true do def rubygems_version(name, requirement) ruby <<-RUBY require "#{spec_dir}/support/artifice/vcr" - require "#{lib_dir}/bundler" - require "#{lib_dir}/bundler/source/rubygems/remote" - require "#{lib_dir}/bundler/fetcher" + require "#{entrypoint}" + require "#{entrypoint}/source/rubygems/remote" + require "#{entrypoint}/fetcher" rubygem = Bundler.ui.silence do source = Bundler::Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")) fetcher = Bundler::Fetcher.new(source) diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb index bad1df93a9..4c2dff466b 100644 --- a/spec/bundler/runtime/inline_spec.rb +++ b/spec/bundler/runtime/inline_spec.rb @@ -2,7 +2,7 @@ RSpec.describe "bundler/inline#gemfile" do def script(code, options = {}) - requires = ["#{lib_dir}/bundler/inline"] + requires = ["#{entrypoint}/inline"] requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice) requires = requires.map {|r| "require '#{r}'" }.join("\n") ruby("#{requires}\n\n" + code, options) @@ -93,7 +93,7 @@ RSpec.describe "bundler/inline#gemfile" do it "lets me use my own ui object" do script <<-RUBY, :artifice => "endpoint" - require '#{lib_dir}/bundler' + require '#{entrypoint}' class MyBundlerUI < Bundler::UI::Silent def confirm(msg, newline = nil) puts "CONFIRMED!" @@ -110,7 +110,7 @@ RSpec.describe "bundler/inline#gemfile" do it "has an option for quiet installation" do script <<-RUBY, :artifice => "endpoint" - require '#{lib_dir}/bundler/inline' + require '#{entrypoint}/inline' gemfile(true, :quiet => true) do source "https://notaserver.com" @@ -136,7 +136,7 @@ RSpec.describe "bundler/inline#gemfile" do it "does not mutate the option argument" do script <<-RUBY - require '#{lib_dir}/bundler' + require '#{entrypoint}' options = { :ui => Bundler::UI::Shell.new } gemfile(false, options) do path "#{lib_path}" do @@ -218,7 +218,7 @@ RSpec.describe "bundler/inline#gemfile" do rake BUNDLED WITH - 1.13.6 + #{Bundler::VERSION} G script <<-RUBY diff --git a/spec/bundler/runtime/load_spec.rb b/spec/bundler/runtime/load_spec.rb index 0274ba18b8..96a22a46cc 100644 --- a/spec/bundler/runtime/load_spec.rb +++ b/spec/bundler/runtime/load_spec.rb @@ -82,7 +82,7 @@ RSpec.describe "Bundler.load" do G ruby <<-RUBY - require "#{lib_dir}/bundler" + require "#{entrypoint}" Bundler.setup :default Bundler.require :default puts RACK diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb index bec42e0f70..d81bccbdf8 100644 --- a/spec/bundler/runtime/platform_spec.rb +++ b/spec/bundler/runtime/platform_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do ruby <<-R begin - require '#{lib_dir}/bundler' + require '#{entrypoint}' Bundler.ui.silence { Bundler.setup } rescue Bundler::GemNotFound => e puts "WIN" diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb index ad30529e86..a3fa4fbe47 100644 --- a/spec/bundler/runtime/require_spec.rb +++ b/spec/bundler/runtime/require_spec.rb @@ -192,7 +192,7 @@ RSpec.describe "Bundler.require" do G cmd = <<-RUBY - require '#{lib_dir}/bundler' + require '#{entrypoint}' Bundler.require RUBY ruby(cmd) diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 46663bc76f..d8ba569f0a 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -108,8 +108,8 @@ RSpec.describe "Bundler.setup" do context "load order" do def clean_load_path(lp) without_bundler_load_path = ruby("puts $LOAD_PATH").split("\n") - lp -= without_bundler_load_path - lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s, lib_dir.to_s}/i, "") } + lp -= [*without_bundler_load_path, lib_dir.to_s] + lp.map! {|p| p.sub(system_gem_path.to_s, "") } end it "puts loaded gems after -I and RUBYLIB", :ruby_repo do @@ -143,12 +143,8 @@ RSpec.describe "Bundler.setup" do gem "rails" G - # We require an absolute path because relying on the $LOAD_PATH behaves - # inconsistently depending on whether we're in a ruby-core setup (and - # bundler's lib is in RUBYLIB) or not. - ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup puts $LOAD_PATH RUBY @@ -157,7 +153,6 @@ RSpec.describe "Bundler.setup" do expect(load_path).to start_with( "/gems/rails-2.3.2/lib", - "/gems/bundler-#{Bundler::VERSION}/lib", "/gems/activeresource-2.3.2/lib", "/gems/activerecord-2.3.2/lib", "/gems/actionpack-2.3.2/lib", @@ -168,6 +163,8 @@ RSpec.describe "Bundler.setup" do end it "falls back to order the load path alphabetically for backwards compatibility" do + bundle "config set path.system true" + install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "weakling" @@ -175,12 +172,8 @@ RSpec.describe "Bundler.setup" do gem "terranova" G - # We require an absolute path because relying on the $LOAD_PATH behaves - # inconsistently depending on whether we're in a ruby-core setup (and - # bundler's lib is in RUBYLIB) or not. - ruby <<-RUBY - require '#{lib_dir}/bundler/setup' + require 'bundler/setup' puts $LOAD_PATH RUBY @@ -200,8 +193,6 @@ RSpec.describe "Bundler.setup" do gem "rack" G - entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" - ruby <<-R require '#{entrypoint}' @@ -474,8 +465,6 @@ RSpec.describe "Bundler.setup" do break_git! - entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" - ruby <<-R require "#{entrypoint}" @@ -493,14 +482,14 @@ RSpec.describe "Bundler.setup" do end it "works even when the cache directory has been deleted" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install FileUtils.rm_rf vendored_gems("cache") expect(the_bundle).to include_gems "rack 1.0.0" end it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install with_read_only("#{bundled_app}/**/*") do @@ -604,7 +593,7 @@ RSpec.describe "Bundler.setup" do describe "when excluding groups" do it "doesn't change the resolve if --without is used" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -620,7 +609,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not bail on bare Bundler.setup" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -636,7 +625,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not bail on bare Bundler.setup, even in the case of path gems no longer available" do - bundle "config --local without development" + bundle "config set --local without development" path = bundled_app(File.join("vendor", "foo")) build_lib "foo", :path => path @@ -656,7 +645,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not include groups passed to Bundler.setup" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -1126,9 +1115,8 @@ end context "is not present" do it "does not change the lock" do - entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" lockfile lock_with(nil) - ruby "require '#{entrypoint}'" + ruby "require '#{entrypoint}/setup'" lockfile_should_be lock_with(nil) end end @@ -1145,10 +1133,9 @@ end context "is older" do it "does not change the lock" do - entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" system_gems "bundler-1.10.1" lockfile lock_with("1.10.1") - ruby "require '#{entrypoint}'" + ruby "require '#{entrypoint}/setup'" lockfile_should_be lock_with("1.10.1") end end @@ -1219,9 +1206,8 @@ end describe "with gemified standard libraries" do it "does not load Psych" do gemfile "" - entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" ruby <<-RUBY - require '#{entrypoint}' + require '#{entrypoint}/setup' puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined" require 'psych' puts Psych::VERSION @@ -1422,9 +1408,4 @@ end expect(last_command.stdboth).to eq("true") end end - - # Tested rubygems does not include https://github.com/rubygems/rubygems/pull/2728 and will not always end up activating the current bundler - def mis_activates_prerelease_default_bundler? - Gem.rubygems_version < Gem::Version.new("3.1.a") - end end diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index d09ccb6e90..36a6bcd099 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -72,6 +72,7 @@ RSpec.configure do |config| Spec::Rubygems.test_setup ENV["BUNDLE_SPEC_RUN"] = "true" ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil + ENV["XDG_CONFIG_HOME"] = nil ENV["GEMRC"] = nil # Don't wrap output in tests diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb index e0650fa7d5..37ca378ef9 100644 --- a/spec/bundler/support/artifice/endpoint.rb +++ b/spec/bundler/support/artifice/endpoint.rb @@ -45,10 +45,14 @@ class Endpoint < Sinatra::Base Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"]) else case request.host + when "gem.repo1" + Spec::Path.gem_repo1 when "gem.repo2" Spec::Path.gem_repo2 when "gem.repo3" Spec::Path.gem_repo3 + when "gem.repo4" + Spec::Path.gem_repo4 else Spec::Path.gem_repo1 end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 73dd508e54..d660a972e3 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -60,7 +60,7 @@ module Spec def run(cmd, *args) opts = args.last.is_a?(Hash) ? args.pop : {} groups = args.map(&:inspect).join(", ") - setup = "require '#{lib_dir}/bundler' ; Bundler.ui.silence { Bundler.setup(#{groups}) }" + setup = "require '#{entrypoint}' ; Bundler.ui.silence { Bundler.setup(#{groups}) }" ruby([setup, cmd].join(" ; "), opts) end diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb index 1f3c4ddaa6..bf4300edb2 100644 --- a/spec/bundler/support/indexes.rb +++ b/spec/bundler/support/indexes.rb @@ -20,12 +20,11 @@ module Spec default_source = instance_double("Bundler::Source::Rubygems", :specs => @index) source_requirements = { :default => default_source } @deps.each do |d| + source_requirements[d.name] = d.source = default_source @platforms.each do |p| - source_requirements[d.name] = d.source = default_source deps << Bundler::DepProxy.get_proxy(d, p) end end - source_requirements ||= {} args[0] ||= [] # base args[1] ||= Bundler::GemVersionPromoter.new # gem_version_promoter args[2] ||= [] # additional_base_requirements diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb index 1613662981..3c1014edc7 100644 --- a/spec/bundler/support/matchers.rb +++ b/spec/bundler/support/matchers.rb @@ -156,7 +156,7 @@ module Spec actual_source = out.split("\n").last next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{actual_source}`" end - next "Command to check forgem inclusion of gem #{full_name} failed" + next "Command to check for inclusion of gem #{full_name} failed" end.compact @errors.empty? diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 483c7da347..dbe5862b44 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -205,6 +205,13 @@ module Spec root.join("lib") end + # Sometimes rubygems version under test does not include + # https://github.com/rubygems/rubygems/pull/2728 and will not always end up + # activating the current bundler. In that case, require bundler absolutely. + def entrypoint + Gem.rubygems_version < Gem::Version.new("3.1.a") ? "#{lib_dir}/bundler" : "bundler" + end + def global_plugin_gem(*args) home ".bundle", "plugin", "gems", *args end |