aspect-build / aspect-build/rules_js
[Bug]: postinstall breaks on some npm packages
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
Some libraries use binaries that it assumes being present on the host machine such as `npm` for example. Below you will find a compilation of libraries that are supposed to work with a traditional `npm | yarn install`:
- [@cubejs-backend/cubestore@0.30.75](https://www.npmjs.com/package/@cubejs-backend/cubestore) that uses `npm config` to somehow use a npm config proxy setting
```
Running lifecycle hooks on npm package @cubejs-backend/cubestore@0.30.75_moment@2.29.4 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh @cubejs-backend/cubestore ... (remaining 2 arguments skipped)
Cube.js Cube Store Installer ---------------------------------------
Command failed: npm config get https-proxy
/bin/sh: npm: command not found
Need some help? -------------------------------------
Ask this question in Cube.js Slack: https://slack.cube.dev
Post an issue: https://github.com/cube-js/cube.js/issues
> @cubejs-backend/cubestore@0.30.75 postinstall /private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@cubejs-backend+cubestore@0.30.75_moment@2.29.4/node_modules/@cubejs-backend/cubestore
> node bin/post-install
===============================================================
Failure while running lifecycle hook for package '@cubejs-backend/cubestore@0.30.75':
Script: 'postinstall'
Command: `node bin/post-install`
Stack trace:
Exit status 1
at EventEmitter. (/private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:73836)
at EventEmitter.emit (node:events:527:28)
at ChildProcess. (/private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:80298)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
===============================================================
```
- `java` node binding: used by the [CubeJS databricks driver](https://www.npmjs.com/package/@cubejs-backend/databricks-jdbc-driver) which throws the following error
```
/private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/node-gyp-bin/node-gyp: line 5: 1010: command not found
> java@0.12.2 install /private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/java@0.12.2/node_modules/java
> node-gyp rebuild
===============================================================
Failure while running lifecycle hook for package 'java@0.12.2':
Script: 'install'
Command: `node-gyp rebuild`
Stack trace:
spawn ENOENT
at ChildProcess. (/private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:80170)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
===============================================================
INFO: Elapsed time: 4.260s, Critical Path: 0.48s
INFO: 1376 processes: 1101 internal, 4 darwin-sandbox, 271 local.
FAILED: Build did NOT complete successfully
```
- @datadog/pprof
```
Running lifecycle hooks on npm package @datadog/pprof@1.1.1 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh @datadog/pprof ../../../external/npm__at_datadog_pprof__1.1.1/package ... (remaining 1 argument skipped)
Use --sandbox_debug to see verbose messages from the sandbox
sh: tsc: command not found
> @datadog/pprof@1.1.1 install /private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/sandbox/darwin-sandbox/15703/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@datadog+pprof@1.1.1/node_modules/@datadog/pprof
> exit 0
> @datadog/pprof@1.1.1 prepare /private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/sandbox/darwin-sandbox/15703/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@datadog+pprof@1.1.1/node_modules/@datadog/pprof
> npm run compile
> @datadog/pprof@1.1.1 compile
> tsc -p .
===============================================================
Failure while running lifecycle hook for package '@datadog/pprof@1.1.1':
Script: 'prepare'
Command: `npm run compile`
Stack trace:
spawn ENOENT
at ChildProcess. (/private/var/tmp/_bazel_tom/73cb73ab0898b3083f041554c626fd30/sandbox/darwin-sandbox/15703/execroot/wm/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:91930)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
===============================================================
```
### Version
Development (host) and target OS/architectures: Darwin arm64
Output of `bazel --version`: 5.1.1
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: 1.10.0
Language(s) and/or frameworks involved: -
### How to reproduce
```shell
Add following npm packages in your package.json file:
- "@cubejs-backend/databricks-jdbc-driver": "0.30.75"
- "@cubejs-backend/cubestore-driver": "0.30.75"
Use them in a rules_js | rules_ts specific target or simply `bazel build //:node_modules`
```
### Any other information?
_No response_
### Fund our work
- [ ] Sponsor our open source work by donating a [bug bounty](https://opencollective.com/aspect-build/)
Contributor guide
Research direction
Reproduce the failure with the listed packages and the `bazel build //:node_modules` target on Darwin arm64. Start by tracing the lifecycle-hook handling in the rules_js setup and compare the missing `npm`, `node-gyp`, and `tsc` commands. Done means the reproduction packages complete their install or prepare hooks successfully without relying on unavailable host executables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100