Skip to content

Commit 8a6b180

Browse files
Merge pull request #7177 from rubygems/universal-platforms-regression
Fix universal lockfiles regression
2 parents 8c0c3b6 + 75d1290 commit 8a6b180

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

bundler/lib/bundler/lazy_specification.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ def materialize_for_installation
122122
# bad gem.
123123
def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
124124
search = candidates.reverse.find do |spec|
125-
spec.is_a?(StubSpecification) ||
126-
(spec.matches_current_ruby? &&
127-
spec.matches_current_rubygems?)
125+
spec.is_a?(StubSpecification) || spec.matches_current_metadata?
128126
end
129127
if search.nil? && fallback_to_non_installable
130128
search = candidates.last

bundler/lib/bundler/match_metadata.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
module Bundler
44
module MatchMetadata
5+
def matches_current_metadata?
6+
matches_current_ruby? && matches_current_rubygems?
7+
end
8+
59
def matches_current_ruby?
610
@required_ruby_version.satisfied_by?(Gem.ruby_version)
711
end

bundler/lib/bundler/spec_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def complete_platforms!(platforms)
6464
valid_platform = lookup.all? do |_, specs|
6565
spec = specs.first
6666
matching_specs = spec.source.specs.search([spec.name, spec.version])
67-
platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).first
67+
platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).find(&:matches_current_metadata?)
6868

6969
if platform_spec
7070
new_specs << LazySpecification.from_spec(platform_spec)

bundler/spec/install/gemfile/specific_platform_spec.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,64 @@
11681168
end
11691169
end
11701170

1171+
it "does not fail when a platform variant is incompatible with the current ruby and another equivalent platform specific variant is part of the resolution", :rubygems => ">= 3.3.21" do
1172+
build_repo4 do
1173+
build_gem "nokogiri", "1.15.5"
1174+
1175+
build_gem "nokogiri", "1.15.5" do |s|
1176+
s.platform = "x86_64-linux"
1177+
s.required_ruby_version = "< #{current_ruby_minor}.dev"
1178+
end
1179+
1180+
build_gem "sass-embedded", "1.69.5"
1181+
1182+
build_gem "sass-embedded", "1.69.5" do |s|
1183+
s.platform = "x86_64-linux-gnu"
1184+
end
1185+
end
1186+
1187+
gemfile <<~G
1188+
source "#{file_uri_for(gem_repo4)}"
1189+
1190+
gem "nokogiri"
1191+
gem "sass-embedded"
1192+
G
1193+
1194+
expected_checksums = checksum_section do |c|
1195+
c.repo_gem gem_repo4, "nokogiri", "1.15.5"
1196+
c.no_checksum "sass-embedded", "1.69.5"
1197+
c.repo_gem gem_repo4, "sass-embedded", "1.69.5", "x86_64-linux-gnu"
1198+
end
1199+
1200+
simulate_platform "x86_64-linux" do
1201+
bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
1202+
1203+
# locks all compatible platforms, excluding Java and Windows
1204+
expect(lockfile).to eq(<<~L)
1205+
GEM
1206+
remote: #{file_uri_for(gem_repo4)}/
1207+
specs:
1208+
nokogiri (1.15.5)
1209+
sass-embedded (1.69.5)
1210+
sass-embedded (1.69.5-x86_64-linux-gnu)
1211+
1212+
PLATFORMS
1213+
ruby
1214+
x86_64-linux
1215+
1216+
DEPENDENCIES
1217+
nokogiri
1218+
sass-embedded
1219+
1220+
CHECKSUMS
1221+
#{expected_checksums}
1222+
1223+
BUNDLED WITH
1224+
#{Bundler::VERSION}
1225+
L
1226+
end
1227+
end
1228+
11711229
private
11721230

11731231
def setup_multiplatform_gem

0 commit comments

Comments
 (0)