From 674c960513b6c77aa4d6e35034441f90fe16a9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 16 Mar 2023 17:45:54 +0100 Subject: [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 --- .../install/gemfile/specific_platform_spec.rb | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'spec/bundler') 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 -- cgit v1.2.3