Skip to content

Commit 4a902d1

Browse files
committed
fix: ensure hermetic Node.js binary is in PATH for npm during jco installation
- Add PATH environment setup so npm can find the hermetic node binary - Fixes CI error: '/usr/bin/env: node: No such file or directory' - npm (which is a Node.js script) needs node in PATH to execute properly - Set NODE_PATH to empty to avoid conflicts with system Node.js
1 parent 3a19309 commit 4a902d1

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

toolchains/jco_toolchain.bzl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,24 @@ def _setup_downloaded_jco_tools(repository_ctx, platform, jco_version, node_vers
170170
print("Installing jco {} using hermetic npm...".format(jco_version))
171171

172172
# Create a local node_modules for jco
173-
npm_install_result = repository_ctx.execute([
174-
npm_binary,
175-
"install",
176-
"--prefix",
177-
"jco_workspace",
178-
"@bytecodealliance/jco@{}".format(jco_version),
179-
"@bytecodealliance/componentize-js", # Required dependency
180-
])
173+
# Set up environment so npm can find node binary
174+
node_dir = str(node_binary.dirname)
175+
npm_env = {
176+
"PATH": node_dir + ":" + repository_ctx.os.environ.get("PATH", ""),
177+
"NODE_PATH": "", # Clear any existing NODE_PATH
178+
}
179+
180+
npm_install_result = repository_ctx.execute(
181+
[
182+
npm_binary,
183+
"install",
184+
"--prefix",
185+
"jco_workspace",
186+
"@bytecodealliance/jco@{}".format(jco_version),
187+
"@bytecodealliance/componentize-js", # Required dependency
188+
],
189+
environment = npm_env,
190+
)
181191

182192
if npm_install_result.return_code != 0:
183193
fail(format_diagnostic_error(

0 commit comments

Comments
 (0)