[rubygems/rubygems] Make sure to not re-resolve when a not fully specific local platform is locked

36a02c6128
This commit is contained in:
David Rodríguez 2024-06-14 11:08:48 +02:00 committed by Hiroshi SHIBATA
parent c6a28b02c9
commit 758e01d39d
2 changed files with 42 additions and 1 deletions

View file

@ -621,11 +621,13 @@ module Bundler
end
def start_resolution
@platforms |= [local_platform]
result = SpecSet.new(resolver.start)
@resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
if @current_ruby_locked_platform && @current_ruby_locked_platform != local_platform
if most_specific_ruby_locked_platform_is_not_local_platform?
@platforms.delete(result.incomplete_for_platform?(dependencies, @current_ruby_locked_platform) ? @current_ruby_locked_platform : local_platform)
end
@ -667,10 +669,15 @@ module Bundler
def add_current_platform
@current_ruby_locked_platform = most_specific_locked_platform if current_ruby_platform_locked?
return if most_specific_ruby_locked_platform_is_not_local_platform?
add_platform(local_platform)
end
def most_specific_ruby_locked_platform_is_not_local_platform?
@current_ruby_locked_platform && @current_ruby_locked_platform != local_platform
end
def change_reason
if unlocking?
unlock_targets = if @gems_to_unlock.any?

View file

@ -1434,6 +1434,40 @@ RSpec.describe "bundle install with specific platforms" do
end
end
it "does not re-resolve when a specific platform, but less specific than the current platform, is locked" do
build_repo4 do
build_gem "nokogiri"
end
gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "nokogiri"
G
lockfile <<~L
GEM
remote: #{file_uri_for(gem_repo4)}/
specs:
nokogiri (1.0)
PLATFORMS
arm64-darwin
DEPENDENCIES
nokogiri!
BUNDLED WITH
#{Bundler::VERSION}
L
simulate_platform "arm64-darwin-23" do
bundle "install --verbose"
expect(out).to include("Found no changes, using resolution from the lockfile")
end
end
private
def setup_multiplatform_gem