[rubygems/rubygems] Excluding local platform from lockfile should not affect musl vs gnu case
This case is for not locking things like `arm-darwin-23` when the lockfile already includes `arm-darwin`, so that we don't infinitely keep redundant versioned platforms in the lockfile when not necessary. We detect this with `Gem::Platform#===`. For example, `Gem::Platform.new("arm-darwin-23") === Gem::Platform.new("arm-darwin")` but they're not `==`. However, in the case of `-musl` vs `-gnu`, those act as the platform "version", but `===` is not commutative for them. This is explained in `===` docs. We only want to exclude the local platform in situations when `Gem::Platform#===` is actually commutative. https://github.com/rubygems/rubygems/commit/8099c4face
This commit is contained in:
parent
814dedcee2
commit
98c84ef42c
@ -65,7 +65,7 @@ module Bundler
|
||||
|
||||
platforms.concat(new_platforms)
|
||||
|
||||
less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && Bundler.local_platform === platform }
|
||||
less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && Bundler.local_platform === platform && platform === Bundler.local_platform }
|
||||
platforms.delete(Bundler.local_platform) if less_specific_platform
|
||||
|
||||
platforms
|
||||
|
@ -1262,43 +1262,47 @@ RSpec.describe "bundle install with specific platforms" do
|
||||
end
|
||||
end
|
||||
|
||||
it "adds current musl platform" do
|
||||
build_repo4 do
|
||||
build_gem "rcee_precompiled", "0.5.0" do |s|
|
||||
s.platform = "x86_64-linux"
|
||||
["x86_64-linux", "x86_64-linux-musl"].each do |host_platform|
|
||||
describe "on host platform #{host_platform}" do
|
||||
it "adds current musl platform" do
|
||||
build_repo4 do
|
||||
build_gem "rcee_precompiled", "0.5.0" do |s|
|
||||
s.platform = "x86_64-linux"
|
||||
end
|
||||
|
||||
build_gem "rcee_precompiled", "0.5.0" do |s|
|
||||
s.platform = "x86_64-linux-musl"
|
||||
end
|
||||
end
|
||||
|
||||
gemfile <<~G
|
||||
source "#{file_uri_for(gem_repo4)}"
|
||||
|
||||
gem "rcee_precompiled", "0.5.0"
|
||||
G
|
||||
|
||||
simulate_platform host_platform do
|
||||
bundle "lock", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
|
||||
|
||||
expect(lockfile).to eq(<<~L)
|
||||
GEM
|
||||
remote: #{file_uri_for(gem_repo4)}/
|
||||
specs:
|
||||
rcee_precompiled (0.5.0-x86_64-linux)
|
||||
rcee_precompiled (0.5.0-x86_64-linux-musl)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
x86_64-linux-musl
|
||||
|
||||
DEPENDENCIES
|
||||
rcee_precompiled (= 0.5.0)
|
||||
|
||||
BUNDLED WITH
|
||||
#{Bundler::VERSION}
|
||||
L
|
||||
end
|
||||
end
|
||||
|
||||
build_gem "rcee_precompiled", "0.5.0" do |s|
|
||||
s.platform = "x86_64-linux-musl"
|
||||
end
|
||||
end
|
||||
|
||||
gemfile <<~G
|
||||
source "#{file_uri_for(gem_repo4)}"
|
||||
|
||||
gem "rcee_precompiled", "0.5.0"
|
||||
G
|
||||
|
||||
simulate_platform "x86_64-linux-musl" do
|
||||
bundle "lock", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
|
||||
|
||||
expect(lockfile).to eq(<<~L)
|
||||
GEM
|
||||
remote: #{file_uri_for(gem_repo4)}/
|
||||
specs:
|
||||
rcee_precompiled (0.5.0-x86_64-linux)
|
||||
rcee_precompiled (0.5.0-x86_64-linux-musl)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
x86_64-linux-musl
|
||||
|
||||
DEPENDENCIES
|
||||
rcee_precompiled (= 0.5.0)
|
||||
|
||||
BUNDLED WITH
|
||||
#{Bundler::VERSION}
|
||||
L
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user