Skip to content

Commit d0bf9ee

Browse files
committed
FIX: workaround missing musl resolution find non musl gem and then lean on glibc that was installed via glibc gem
1 parent 1cbec75 commit d0bf9ee

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

ext/mini_racer_extension/extconf.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@
1111
gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
1212
require 'libv8-node'
1313

14+
# Fix for missing aarch64-linux-musl gem in libv8-node
15+
# On some platforms (like ARM64 Alpine), the musl-specific gem might be missing.
16+
# We fallback to the glibc gem's directory if the musl one isn't found.
17+
if RUBY_PLATFORM.include?('musl')
18+
module Libv8::Node::Paths
19+
def self.platform
20+
@platform ||= begin
21+
# Replicate libv8-node's platform detection logic without side effects
22+
detected_platform = Gem::Platform.local.dup
23+
if detected_platform.version.nil?
24+
detected_platform.instance_eval { @version = 'musl' }
25+
end
26+
27+
platform_name = detected_platform.to_s.gsub(/-darwin-?\d+/, '-darwin')
28+
29+
# If the musl-specific directory is missing, try falling back to glibc
30+
unless File.exist?(File.join(vendored_source_path, platform_name))
31+
fallback = platform_name.gsub('-musl', '')
32+
if File.exist?(File.join(vendored_source_path, fallback))
33+
platform_name = fallback
34+
end
35+
end
36+
37+
platform_name
38+
end
39+
end
40+
end
41+
end
42+
1443
IS_DARWIN = RUBY_PLATFORM =~ /darwin/
1544

1645
have_library('pthread')

0 commit comments

Comments
 (0)