Skip to content

Commit dd0c94f

Browse files
Bo98deivid-rodriguez
authored andcommitted
Map 'universal' to the real arch in Bundler for prebuilt gem selection
1 parent 1702a04 commit dd0c94f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bundler/lib/bundler/rubygems_ext.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,28 @@ def match_platforms?(platform, platforms)
308308
end
309309
end
310310

311+
# On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
312+
class Specification
313+
if /^universal\.(?<arch>.*?)-/ =~ RUBY_PLATFORM
314+
local_platform = Platform.local
315+
if local_platform.cpu == "universal"
316+
ORIGINAL_LOCAL_PLATFORM = local_platform.to_s.freeze
317+
318+
local_platform.cpu = if arch == "arm64e" # arm64e is only permitted for Apple system binaries
319+
"arm64"
320+
else
321+
arch
322+
end
323+
324+
def extensions_dir
325+
Gem.default_ext_dir_for(base_dir) ||
326+
File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM,
327+
Gem.extension_api_version)
328+
end
329+
end
330+
end
331+
end
332+
311333
require "rubygems/util"
312334

313335
Util.singleton_class.module_eval do

0 commit comments

Comments
 (0)