Skip to content

Commit

Permalink
[rubygems/rubygems] Fix musl platform not being added to the lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jan 31, 2024
1 parent c28ee91 commit 95c9711
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/spec_set.rb
Expand Up @@ -65,7 +65,7 @@ def add_extra_platforms!(platforms)

platforms.concat(new_platforms)

less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && platform === Bundler.local_platform }
less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && Bundler.local_platform === platform }
platforms.delete(Bundler.local_platform) if less_specific_platform

platforms
Expand Down
114 changes: 114 additions & 0 deletions spec/bundler/install/gemfile/specific_platform_spec.rb
Expand Up @@ -1262,6 +1262,120 @@
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"
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

it "adds current musl platform, when there are also gnu variants", rubygems: ">= 3.3.21" do
build_repo4 do
build_gem "rcee_precompiled", "0.5.0" do |s|
s.platform = "x86_64-linux-gnu"
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-gnu)
rcee_precompiled (0.5.0-x86_64-linux-musl)
PLATFORMS
x86_64-linux-gnu
x86_64-linux-musl
DEPENDENCIES
rcee_precompiled (= 0.5.0)
BUNDLED WITH
#{Bundler::VERSION}
L
end
end

it "does not add current platform if there's an equivalent less specific platform among the ones resolved" do
build_repo4 do
build_gem "rcee_precompiled", "0.5.0" do |s|
s.platform = "universal-darwin"
end
end

gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "rcee_precompiled", "0.5.0"
G

simulate_platform "x86_64-darwin-15" 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-universal-darwin)
PLATFORMS
universal-darwin
DEPENDENCIES
rcee_precompiled (= 0.5.0)
BUNDLED WITH
#{Bundler::VERSION}
L
end
end

private

def setup_multiplatform_gem
Expand Down

0 comments on commit 95c9711

Please sign in to comment.