Skip to content

Commit

Permalink
Fix ruby cache key calculation used for npm packaging
Browse files Browse the repository at this point in the history
The `RUBY_WASM_ROOT` environment variable is not set when calculating
ruby cache keys for npm packages and rbwasm assumes that the
build_manifest.json file is placed in the cwd (npm package directory).
But the build_manifest.json file is placed in the repository root
so the cache key calculation didn't respect the pinned ruby revision.
  • Loading branch information
kateinoigakukun committed Jun 5, 2024
1 parent 3040942 commit fac40c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ class BuildTask < Struct.new(:name, :target, :build_command)
def ruby_cache_key
return @key if @key
require "open3"
env = { "RUBY_WASM_ROOT" => LIB_ROOT }
cmd = build_command + ["--print-ruby-cache-key"]
stdout, status = Open3.capture2(*cmd)
stdout, status = Open3.capture2(env, *cmd)
unless status.success?
raise "Command failed with status (#{status.exitstatus}): #{cmd.join " "}"
end
Expand Down
3 changes: 2 additions & 1 deletion rakelib/packaging.rake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def npm_pkg_rubies_cache_key(pkg)
require "open3"
cmd = build_command + ["--print-ruby-cache-key"]
chdir = pkg[:gemfile] ? File.dirname(pkg[:gemfile]) : Dir.pwd
stdout, status = Open3.capture2(*cmd, chdir: chdir)
env = { "RUBY_WASM_ROOT" => LIB_ROOT }
stdout, status = Open3.capture2(env, *cmd, chdir: chdir)
unless status.success?
raise "Command failed with status (#{status.exitstatus}): #{cmd.join " "}"
end
Expand Down

0 comments on commit fac40c1

Please sign in to comment.