From 492e70c7b4303ffea8f8c07797e1696b90ce1d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 5 Aug 2022 13:24:24 +0200 Subject: [PATCH] [rubygems/rubygems] Fix `gem install` still choosing musl incorrectly https://github.com/rubygems/rubygems/commit/1b9f7f50a5 --- lib/rubygems/platform.rb | 2 +- test/rubygems/test_gem_resolver.rb | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 1f699c23e0..78fff703a2 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -25,7 +25,7 @@ class Gem::Platform platforms.any? do |local_platform| platform.nil? || local_platform == platform || - (local_platform != Gem::Platform::RUBY && local_platform =~ platform) + (local_platform != Gem::Platform::RUBY && platform =~ local_platform) end end private_class_method :match_platforms? diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index 065143ef33..c816d5484b 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -356,6 +356,41 @@ class TestGemResolver < Gem::TestCase assert_resolves_to [a2_p1.spec], res end + def test_does_not_pick_musl_variants_on_non_musl_linux + util_set_arch "aarch64-linux" do + is = Gem::Resolver::IndexSpecification + + linux_musl = Gem::Platform.new("aarch64-linux-musl") + + spec_fetcher do |fetcher| + fetcher.spec "libv8-node", "15.14.0.1" do |s| + s.platform = Gem::Platform.local + end + + fetcher.spec "libv8-node", "15.14.0.1" do |s| + s.platform = linux_musl + end + end + + v15 = v("15.14.0.1") + source = Gem::Source.new @gem_repo + + s = set + + v15_linux = is.new s, "libv8-node", v15, source, Gem::Platform.local.to_s + v15_linux_musl = is.new s, "libv8-node", v15, source, linux_musl.to_s + + s.add v15_linux + s.add v15_linux_musl + + ad = make_dep "libv8-node", "= 15.14.0.1" + + res = Gem::Resolver.new([ad], s) + + assert_resolves_to [v15_linux.spec], res + end + end + def test_only_returns_spec_once a1 = util_spec "a", "1", "c" => "= 1" b1 = util_spec "b", "1", "c" => "= 1"