aspect-build / aspect-build/bazel-examples
[FR]: Add an example that skips `node-gyp` installs
- Dominant language
- Starlark
- Stars
- 149
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
### What is the current behavior?
Post install hooks can fail with pnpm. One that I ran into was
```
❯ bazel test //bazel/release/internal/pusher:test
INFO: Invocation ID: f430ce78-99c5-461c-84f5-b135bd3fc6e5
INFO: Analyzed target //bazel/release/internal/pusher:test (2296 packages loaded, 35938 targets configured).
INFO: Found 1 test target...
ERROR: /Users/davidaghassi/robinhood/rh_other_alt/bazel/release/internal/pusher/BUILD.bazel:9:22: Running lifecycle hooks on npm package cpu-features@0.0.4 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command (from target //bazel/release/internal/pusher:.aspect_rules_js/node_modules/cpu-features@0.0.4/lc) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh cpu-features ../../../external/pusher_pnpm_deps__cpu-features__0.0.4/package ... (remaining 1 argument skipped)
/private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/node-gyp-bin/node-gyp: line 5: 1211: command not found
> cpu-features@0.0.4 install /private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/bazel/release/internal/pusher/node_modules/.aspect_rules_js/cpu-features@0.0.4/node_modules/cpu-features
> node buildcheck.js > buildcheck.gypi && node-gyp rebuild
===============================================================
Failure while running lifecycle hook for package 'cpu-features@0.0.4':
Script: 'install'
Command: `node buildcheck.js > buildcheck.gypi && node-gyp rebuild`
Stack trace:
spawn ENOENT
at ChildProcess. (/private/var/tmp/_bazel_davidaghassi/299af5c32fa95b8ba15b1237ac8646db/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:91930)
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)
===============================================================
```
having docs/example/suggestion on how to solve this would make error handling better.
### Describe the feature
Adding this fix https://github.com/pnpm/pnpm/issues/4347#issuecomment-1044043721 to my `package.json` resolved my issue and let me continue building/testing.
The reason this is hard to troubleshoot is because outside of bazel, running `pnpm i` works fine.
### Fund our work
- [ ] Sponsor our open source work by donating a [feature bounty](https://opencollective.com/aspect-build/)
Contributor guide
Research direction
Start with the package.json workaround linked in the issue and the pnpm issue comment, then inspect the repository's existing examples for where this scenario belongs. Add an example showing how to skip the failing node-gyp install and verify that the relevant Bazel build or test completes without the lifecycle-hook failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100