1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Fix resolution on non-musl platforms

Gems without specific platform were being preferred over matching
platform specific gems.

https://github.com/rubygems/rubygems/commit/37b95b9159
This commit is contained in:
David Rodríguez 2022-09-07 23:01:03 +02:00 committed by git
parent cfe10e482e
commit b350053ae4
2 changed files with 34 additions and 1 deletions

View file

@ -246,7 +246,7 @@ class Gem::Resolver
sources.each do |source|
groups[source].
sort_by {|spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }.
sort_by {|spec| [spec.version, spec.platform =~ Gem::Platform.local ? 1 : 0] }.
map {|spec| ActivationRequest.new spec, dependency }.
each {|activation_request| activation_requests << activation_request }
end

View file

@ -391,6 +391,39 @@ class TestGemResolver < Gem::TestCase
end
end
def test_pick_generic_linux_variants_on_musl_linux
util_set_arch "aarch64-linux-musl" do
is = Gem::Resolver::IndexSpecification
linux = Gem::Platform.new("aarch64-linux")
spec_fetcher do |fetcher|
fetcher.spec "libv8-node", "15.14.0.1" do |s|
s.platform = linux
end
fetcher.spec "libv8-node", "15.14.0.1"
end
v15 = v("15.14.0.1")
source = Gem::Source.new @gem_repo
s = set
v15_ruby = is.new s, "libv8-node", v15, source, Gem::Platform::RUBY
v15_linux = is.new s, "libv8-node", v15, source, linux.to_s
s.add v15_linux
s.add v15_ruby
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"