From fac40c1b7ffcb65b8c25e3c7c719fd1eac885e47 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 5 Jun 2024 15:21:33 +0000 Subject: [PATCH] Fix ruby cache key calculation used for npm packaging 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. --- Rakefile | 3 ++- rakelib/packaging.rake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 7abb758c6e..d10148a861 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/rakelib/packaging.rake b/rakelib/packaging.rake index bc7bf01576..35a5d1192b 100644 --- a/rakelib/packaging.rake +++ b/rakelib/packaging.rake @@ -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