aspect-build / rules_js

High-performance Bazel rules for running Node.js tools and building JavaScript projects
https://docs.aspect.build/rules/aspect_rules_js
Apache License 2.0
301 stars 105 forks source link

[Bug]: `JS_BINARY__NPM_BINARY: unbound variable` in lifecycle hook execution that uses `npm` #1200

Open matthewjh opened 1 year ago

matthewjh commented 1 year ago

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.<anonymous> (/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.<anonymous> (/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

alexeagle commented 1 year ago

I'm not sure whether to expect a postinstall like that to work correctly under rules_js or not.

That include_npm attribute you point to has been there since https://github.com/aspect-build/rules_js/commit/70f46edc780ea5c449174a324f756a3e9feefc25 by @gregmagolan.