aspect-build / aspect-build/rules_js
[Bug]: `JS_BINARY__NPM_BINARY: unbound variable` in lifecycle hook execution that uses `npm`
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
https://github.com/aspect-build/rules_js/blob/77314279d52c4e97233859f8148002f1f715dbd5/npm/private/lifecycle/BUILD.bazel#L11 makes me feel like this is intended to be supported, so I thought I'd flag this
Unfortunately the package in question is internal and I'm not allowed to share it.
```
ERROR: BUILD:9:22: Running lifecycle hooks on npm package @tw/trading@0.0.94_758178459 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command (from target //:.aspect_rules_js/node_modules/@tw+trading@0.0.94_758178459/lc) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh @tw/trading ../../../external/npm_deps__at_tw_trading__0.0.94__758178459/package ... (remaining 1 argument skipped)
/Users/mhill/bazel/3c3e59429c86c7585f0ffa57350a75ac/execroot/web/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles/web/../aspect_rules_js/npm/private/lifecycle/lifecycle-hooks_node_bin/npm: line 5: JS_BINARY__NPM_BINARY: unbound variable
> @tw/trading@0.0.94 install /Users/mhill/bazel/3c3e59429c86c7585f0ffa57350a75ac/execroot/web/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@tw+trading@0.0.94_758178459/node_modules/@tw/trading
> npm run install-debug
===============================================================
Failure while running lifecycle hook for package '@tw/trading@0.0.94':
Script: 'install'
Command: `npm run install-debug`
Stack trace:
Exit status 1
at EventEmitter. (/Users/mhill/bazel/3c3e59429c86c7585f0ffa57350a75ac/execroot/web/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:47:92054)
at EventEmitter.emit (node:events:513:28)
at ChildProcess. (/Users/mhill/bazel/3c3e59429c86c7585f0ffa57350a75ac/execroot/web/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:195024)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
===============================================================
```
### Version
Development (host) and target OS/architectures:
macos arm64
Output of `bazel --version`:
6.3.1
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
http_archive(
name = "rules_nodejs",
sha256 = "08337d4fffc78f7fe648a93be12ea2fc4e8eb9795a4e6aa48595b66b34555626",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-core-5.8.0.tar.gz"],
)
http_archive(
name = "aspect_rules_js",
sha256 = "7b2a4d1d264e105eae49a27e2e78065b23e2e45724df2251eacdd317e95bfdfd",
strip_prefix = "rules_js-1.31.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.31.0/rules_js-v1.31.0.tar.gz",
)
### How to reproduce
_No response_
### Any other information?
_No response_
Contributor guide
Research direction
Start with npm/private/lifecycle/BUILD.bazel at the referenced line, then inspect npm/private/lifecycle/lifecycle-hooks.sh and the generated lifecycle-hooks_node_bin/npm wrapper around the JS_BINARY__NPM_BINARY failure. Reproduce with the reported Bazel 6.3.1, rules_js 1.31.0, macOS arm64 setup if possible; done means an npm lifecycle hook runs without the unbound-variable error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100