diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2023-03-16 17:45:54 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-28 15:25:42 +0900 |
commit | 674c960513b6c77aa4d6e35034441f90fe16a9da (patch) | |
tree | f0bbcedaae734c0571ddf94fcba5b960da234377 | |
parent | ed868f9a71707d5f51caddbf345e0fde8c940c42 (diff) |
[rubygems/rubygems] Fix incorrect removal of "ruby" platform from lockfile
When dependencies have changed, we'll be re-resolving, and we can't
really know whether the resolution will be valid or invalid for the Ruby
platform, so skip the removal in that case.
The fix worked, but made some other specs fail, and surfaced that the
`@dependencies_changed` attribute was actually being incorrect set when
explicitly unlocking. Fixed that with an early return.
https://github.com/rubygems/rubygems/commit/20d8f5e5d9
-rw-r--r-- | lib/bundler/definition.rb | 3 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/specific_platform_spec.rb | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 5b0db19b87..9467d312fa 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -726,6 +726,8 @@ module Bundler dep.source = sources.get(dep.source) end + next if unlocking? + unless locked_dep = @locked_deps[dep.name] changes = true next @@ -899,6 +901,7 @@ module Bundler Bundler.local_platform == Gem::Platform::RUBY || !platforms.include?(Gem::Platform::RUBY) || (@new_platform && platforms.last == Gem::Platform::RUBY) || + @dependency_changes || !@originally_locked_specs.incomplete_ruby_specs?(dependencies) remove_platform(Gem::Platform::RUBY) diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index ce148af43d..6974af3270 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -786,6 +786,56 @@ RSpec.describe "bundle install with specific platforms" do expect(lockfile).to eq(original_lockfile) end + it "does not remove ruby when adding a new gem to the Gemfile" do + build_repo4 do + build_gem "concurrent-ruby", "1.2.2" + build_gem "rack", "3.0.7" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "concurrent-ruby" + gem "rack" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + concurrent-ruby (1.2.2) + + PLATFORMS + ruby + + DEPENDENCIES + concurrent-ruby + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "lock" + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + concurrent-ruby (1.2.2) + rack (3.0.7) + + PLATFORMS + #{formatted_lockfile_platforms(*["ruby", generic_local_platform].uniq)} + + DEPENDENCIES + concurrent-ruby + rack + + BUNDLED WITH + #{Bundler::VERSION} + L + end + it "can fallback to a source gem when platform gems are incompatible with current ruby version" do setup_multiplatform_gem_with_source_gem |