Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect bundle update --bundler message #7516

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundler/lib/bundler/self_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def resolve_update_version_from(target)
end

def local_specs
@local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
@local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true, "allow_cached" => true).specs.select {|spec| spec.name == "bundler" }
end

def remote_specs
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(options = {})
@remotes = []
@dependency_names = []
@allow_remote = false
@allow_cached = false
@allow_cached = options["allow_cached"] || false
@allow_local = options["allow_local"] || false
@checksum_store = Checksum::Store.new

Expand Down Expand Up @@ -133,7 +133,7 @@ def specs
# sources, and large_idx.merge! small_idx is way faster than
# small_idx.merge! large_idx.
index = @allow_remote ? remote_specs.dup : Index.new
index.merge!(cached_specs) if @allow_cached || @allow_remote
index.merge!(cached_specs) if @allow_cached
index.merge!(installed_specs) if @allow_local
index
end
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/source_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SourceList
:metadata_source

def global_rubygems_source
@global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
@global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true, "allow_cached" => true)
end

def initialize
Expand Down Expand Up @@ -174,7 +174,7 @@ def global_replacement_source(replacement_sources)
replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
return global_rubygems_source unless replacement_source

replacement_source.local!
replacement_source.cached!
replacement_source
end

Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def bin_path(a,b,c)
let(:exit_code) { Bundler::GemNotFound.new.status_code }
let(:expected) { "" }
let(:expected_err) { <<-EOS.strip }
Could not find gem 'rack (= 2)' in locally installed gems.
Could not find gem 'rack (= 2)' in cached gems or installed locally.

The source contains the following gems matching 'rack':
* rack-0.9.1
Expand Down Expand Up @@ -915,7 +915,7 @@ def bin_path(a,b,c)
let(:exit_code) { Bundler::GemNotFound.new.status_code }
let(:expected) { "" }
let(:expected_err) { <<-EOS.strip }
Could not find gem 'rack (= 2)' in locally installed gems.
Could not find gem 'rack (= 2)' in cached gems or installed locally.

The source contains the following gems matching 'rack':
* rack-1.0.0
Expand Down
6 changes: 3 additions & 3 deletions bundler/spec/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
it "does not fetch remote specs when using the --local option" do
bundle "lock --update --local", raise_on_error: false

expect(err).to match(/locally installed gems/)
expect(err).to match(/cached gems or installed locally/)
end

it "does not fetch remote checksums with --local" do
Expand Down Expand Up @@ -1211,7 +1211,7 @@
Because rails >= 7.0.4 depends on railties = 7.0.4
and rails < 7.0.4 depends on railties = 7.0.3.1,
railties = 7.0.3.1 OR = 7.0.4 is required.
So, because railties = 7.0.3.1 OR = 7.0.4 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally,
So, because railties = 7.0.3.1 OR = 7.0.4 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally,
version solving has failed.
ERR
end
Expand Down Expand Up @@ -1322,7 +1322,7 @@
Thus, rails >= 7.0.2.3, < 7.0.4 cannot be used.
And because rails >= 7.0.4 depends on activemodel = 7.0.4,
rails >= 7.0.2.3 requires activemodel = 7.0.4.
So, because activemodel = 7.0.4 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally
So, because activemodel = 7.0.4 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally
and Gemfile depends on rails >= 7.0.2.3,
version solving has failed.
ERR
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/commands/post_bundle_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
gem "not-a-gem", :group => :development
G
expect(err).to include <<-EOS.strip
Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally.
Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)}/, cached gems or installed locally.
EOS
end

Expand Down
37 changes: 37 additions & 0 deletions bundler/spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,43 @@
end
end

it "does not claim to update to Bundler version to a wrong version when cached gems are present" do
pristine_system_gems "bundler-2.99.0"

build_repo4 do
build_gem "rack", "3.0.9.1"

build_bundler "2.99.0"
end

gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "rack"
G

lockfile <<~L
GEM
remote: #{file_uri_for(gem_repo4)}/
specs:
rack (3.0.9.1)

PLATFORMS
#{lockfile_platforms}

DEPENDENCIES
rack

BUNDLED WITH
2.99.0
L

bundle :cache, verbose: true

bundle :update, bundler: true, artifice: "compact_index", verbose: true, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }

expect(out).not_to include("Updating bundler to")
end

it "does not update the bundler version in the lockfile if the latest version is not compatible with current ruby", :ruby_repo do
pristine_system_gems "bundler-2.3.9"

Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@
gem "has_submodule"
end
G
expect(err).to match(%r{submodule >= 0 could not be found in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally})
expect(err).to match(%r{submodule >= 0 could not be found in rubygems repository #{file_uri_for(gem_repo1)}/, cached gems or installed locally})

expect(the_bundle).not_to include_gems "has_submodule 1.0"
end
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/install/gemfile/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@

it "fails" do
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("Could not find gem 'private_gem_1' in rubygems repository https://gem.repo2/, cached gems or installed locally.")
end
end

Expand Down Expand Up @@ -611,7 +611,7 @@
Could not find compatible versions

Because every version of depends_on_rack depends on rack >= 0
and rack >= 0 could not be found in rubygems repository https://gem.repo2/ or installed locally,
and rack >= 0 could not be found in rubygems repository https://gem.repo2/, cached gems or installed locally,
depends_on_rack cannot be used.
So, because Gemfile depends on depends_on_rack >= 0,
version solving has failed.
Expand Down
6 changes: 3 additions & 3 deletions bundler/spec/install/gemfile/specific_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
G

error_message = <<~ERROR.strip
Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally.

The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
* sorbet-static-0.5.6433-universal-darwin-20
Expand Down Expand Up @@ -434,7 +434,7 @@
Could not find compatible versions

Because every version of sorbet depends on sorbet-static = 0.5.6433
and sorbet-static = 0.5.6433 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally for any resolution platforms (arm64-darwin-21),
and sorbet-static = 0.5.6433 could not be found in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally for any resolution platforms (arm64-darwin-21),
sorbet cannot be used.
So, because Gemfile depends on sorbet = 0.5.6433,
version solving has failed.
Expand Down Expand Up @@ -473,7 +473,7 @@
bundle "lock", raise_on_error: false, env: { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" }

expect(err).to include <<~ERROR.rstrip
Could not find gem 'sorbet-static (= 0.5.9889)' with platform 'ruby' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
Could not find gem 'sorbet-static (= 0.5.9889)' with platform 'ruby' in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally.

The source contains the following gems matching 'sorbet-static (= 0.5.9889)':
* sorbet-static-0.5.9889-#{Gem::Platform.local}
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/install/gems/flex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
Could not find compatible versions

Because rack-obama >= 2.0 depends on rack = 1.2
and rack = 1.2 could not be found in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally,
and rack = 1.2 could not be found in rubygems repository #{file_uri_for(gem_repo2)}/, cached gems or installed locally,
rack-obama >= 2.0 cannot be used.
So, because Gemfile depends on rack-obama = 2.0,
version solving has failed.
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/install/gems/resolving_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
end

nice_error = <<~E.strip
Could not find gems matching 'sorbet-static (= 0.5.10554)' valid for all resolution platforms (arm64-darwin-21, aarch64-linux) in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
Could not find gems matching 'sorbet-static (= 0.5.10554)' valid for all resolution platforms (arm64-darwin-21, aarch64-linux) in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally.

The source contains the following gems matching 'sorbet-static (= 0.5.10554)':
* sorbet-static-0.5.10554-universal-darwin-21
Expand Down Expand Up @@ -490,7 +490,7 @@

it "raises a proper error" do
nice_error = <<~E.strip
Could not find gems matching 'sorbet-static' valid for all resolution platforms (arm-linux, x86_64-linux) in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
Could not find gems matching 'sorbet-static' valid for all resolution platforms (arm-linux, x86_64-linux) in rubygems repository #{file_uri_for(gem_repo4)}/, cached gems or installed locally.

The source contains the following gems matching 'sorbet-static':
* sorbet-static-0.5.10696-x86_64-linux
Expand Down
6 changes: 3 additions & 3 deletions bundler/spec/install/yanked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@

bundle :list, raise_on_error: false

expect(err).to include("Could not find rack-0.9.1 in locally installed gems")
expect(err).to include("Could not find rack-0.9.1 in cached gems or installed locally")
expect(err).to_not include("Your bundle is locked to rack (0.9.1) from")
expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
Expand All @@ -197,7 +197,7 @@
lockfile lockfile.gsub(/PLATFORMS\n #{lockfile_platforms}/m, "PLATFORMS\n #{lockfile_platforms("ruby")}")

bundle :list, raise_on_error: false
expect(err).to include("Could not find rack-0.9.1 in locally installed gems")
expect(err).to include("Could not find rack-0.9.1 in cached gems or installed locally")
end

it "does not suggest the author has yanked the gem when using more than one gem, but shows all gems that couldn't be found in the source" do
Expand All @@ -224,7 +224,7 @@

bundle :list, raise_on_error: false

expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in locally installed gems")
expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in cached gems or installed locally")
expect(err).to include("Install missing gems with `bundle install`.")
expect(err).to_not include("Your bundle is locked to rack (0.9.1) from")
expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
Expand Down