Skip to content

Commit 9e66103

Browse files
Fix precompiled extension loading
1 parent 9abee2c commit 9e66103

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/ruby_wasm/cli.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ def do_print_ruby_cache_key(packager)
180180
end
181181

182182
def do_build(executor, tmpdir, packager, options)
183-
require_relative "ruby_wasm.so"
183+
# Tries to require the extension for the given Ruby version first
184+
begin
185+
RUBY_VERSION =~ /(\d+\.\d+)/
186+
require_relative "#{Regexp.last_match(1)}/ruby_wasm.so"
187+
rescue LoadError
188+
require_relative "ruby_wasm.so"
189+
end
184190
wasm_bytes = packager.package(executor, tmpdir, options)
185191
RubyWasm.logger.info "Size: #{SizeFormatter.format(wasm_bytes.size)}"
186192
case options[:output]

0 commit comments

Comments
 (0)