Skip to content

Commit 95c9711

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix musl platform not being added to the lockfile
rubygems/rubygems@235f7b4266
1 parent c28ee91 commit 95c9711

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

lib/bundler/spec_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def add_extra_platforms!(platforms)
6565

6666
platforms.concat(new_platforms)
6767

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

7171
platforms

spec/bundler/install/gemfile/specific_platform_spec.rb

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,120 @@
12621262
end
12631263
end
12641264

1265+
it "adds current musl platform" do
1266+
build_repo4 do
1267+
build_gem "rcee_precompiled", "0.5.0" do |s|
1268+
s.platform = "x86_64-linux"
1269+
end
1270+
1271+
build_gem "rcee_precompiled", "0.5.0" do |s|
1272+
s.platform = "x86_64-linux-musl"
1273+
end
1274+
end
1275+
1276+
gemfile <<~G
1277+
source "#{file_uri_for(gem_repo4)}"
1278+
1279+
gem "rcee_precompiled", "0.5.0"
1280+
G
1281+
1282+
simulate_platform "x86_64-linux-musl" do
1283+
bundle "lock", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
1284+
1285+
expect(lockfile).to eq(<<~L)
1286+
GEM
1287+
remote: #{file_uri_for(gem_repo4)}/
1288+
specs:
1289+
rcee_precompiled (0.5.0-x86_64-linux)
1290+
rcee_precompiled (0.5.0-x86_64-linux-musl)
1291+
1292+
PLATFORMS
1293+
x86_64-linux
1294+
x86_64-linux-musl
1295+
1296+
DEPENDENCIES
1297+
rcee_precompiled (= 0.5.0)
1298+
1299+
BUNDLED WITH
1300+
#{Bundler::VERSION}
1301+
L
1302+
end
1303+
end
1304+
1305+
it "adds current musl platform, when there are also gnu variants", rubygems: ">= 3.3.21" do
1306+
build_repo4 do
1307+
build_gem "rcee_precompiled", "0.5.0" do |s|
1308+
s.platform = "x86_64-linux-gnu"
1309+
end
1310+
1311+
build_gem "rcee_precompiled", "0.5.0" do |s|
1312+
s.platform = "x86_64-linux-musl"
1313+
end
1314+
end
1315+
1316+
gemfile <<~G
1317+
source "#{file_uri_for(gem_repo4)}"
1318+
1319+
gem "rcee_precompiled", "0.5.0"
1320+
G
1321+
1322+
simulate_platform "x86_64-linux-musl" do
1323+
bundle "lock", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
1324+
1325+
expect(lockfile).to eq(<<~L)
1326+
GEM
1327+
remote: #{file_uri_for(gem_repo4)}/
1328+
specs:
1329+
rcee_precompiled (0.5.0-x86_64-linux-gnu)
1330+
rcee_precompiled (0.5.0-x86_64-linux-musl)
1331+
1332+
PLATFORMS
1333+
x86_64-linux-gnu
1334+
x86_64-linux-musl
1335+
1336+
DEPENDENCIES
1337+
rcee_precompiled (= 0.5.0)
1338+
1339+
BUNDLED WITH
1340+
#{Bundler::VERSION}
1341+
L
1342+
end
1343+
end
1344+
1345+
it "does not add current platform if there's an equivalent less specific platform among the ones resolved" do
1346+
build_repo4 do
1347+
build_gem "rcee_precompiled", "0.5.0" do |s|
1348+
s.platform = "universal-darwin"
1349+
end
1350+
end
1351+
1352+
gemfile <<~G
1353+
source "#{file_uri_for(gem_repo4)}"
1354+
1355+
gem "rcee_precompiled", "0.5.0"
1356+
G
1357+
1358+
simulate_platform "x86_64-darwin-15" do
1359+
bundle "lock", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
1360+
1361+
expect(lockfile).to eq(<<~L)
1362+
GEM
1363+
remote: #{file_uri_for(gem_repo4)}/
1364+
specs:
1365+
rcee_precompiled (0.5.0-universal-darwin)
1366+
1367+
PLATFORMS
1368+
universal-darwin
1369+
1370+
DEPENDENCIES
1371+
rcee_precompiled (= 0.5.0)
1372+
1373+
BUNDLED WITH
1374+
#{Bundler::VERSION}
1375+
L
1376+
end
1377+
end
1378+
12651379
private
12661380

12671381
def setup_multiplatform_gem

0 commit comments

Comments
 (0)