aspect-build / aspect-build/rules_js
[Bug]: `genrule` using `$(NODE_PATH)` doesn't install/resolve correctly when using `container_image` on mac
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
I'm using a `genrule` rule, similar to [the example](https://github.com/aspect-build/rules_js/blob/main/examples/genrule/BUILD.bazel#L30) to run tailwind cli for my project.
I then want to include the output into a container image, using rules_docker's container_image, which includes transitions to `linux` host on macOS (totally expected because of the way docker works on Mac).
This transition causes the nodejs toolchain, and therefore `$(NODE_PATH)` to resolve to the `linux` toolchain, which won't execute on Mac:
```
...
external/nodejs_linux_amd64/bin/nodejs/bin/node: cannot execute binary file
...
```
It's specifically the `container_image` transition, as `container_layer` using the genrule output succeeds as well.
### Version
Development (host) and target OS/architectures:
host: Mac amd64
target: linux amd64 (via docker_rules transition)
Output of `bazel --version`:
Bazel 6.0.0
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
rules_docker: 0.25.0
rules_js: 1.11.1
Language(s) and/or frameworks involved:
n/a
### How to reproduce
```shell
Steps are above, but I've created a [repro repo here](https://github.com/snapbug/js_docker_repro), which has the various rules and which fails and why in the README.md
```
### 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
Start with the linked js_docker_repro README and the rules_js examples/genrule/BUILD.bazel example, then reproduce the failure with Bazel 6.0.0, rules_docker 0.25.0, and rules_js 1.11.1 on Mac amd64. Compare the genrule output through container_image with the successful container_layer path; done means container_image no longer tries to execute the Linux nodejs binary for $(NODE_PATH).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, node.js
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100