aspect-build / aspect-build/rules_js
[FR]: Support running @pnpm//:pnpm with a different current dir other than the default.
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What is the current behavior?
FATAL: aspect_rules_js[js_binary]: BAZEL_BINDIR must be set in environment to the makevar $(BINDIR) in js_binary build actions (which run in the execroot) so that build actions can change directories to always run out of the root of the Bazel output tree. See https://docs.bazel.build/versions/main/be/make-variables.html#predefined_variables. This is automatically set by 'js_run_binary' (https://github.com/aspect-build/rules_js/blob/main/docs/js_run_binary.md) which is the recommended rule to use for using a js_binary as the tool of a build action. If this is not a build action you can set the BAZEL_BINDIR to '.' instead to supress this error. For more context on this design decision, please read the aspect_rules_js README https://github.com/aspect-build/rules_js/tree/dbb5af0d2a9a2bb50e4cf4a96dbc582b27567155#running-nodejs-programs.
### Describe the feature
Hi all, I have a custom run_under script that does the following.
```sh
#!/usr/bin/env bash
set -euo pipefail
if [[ "${SCUFFLE_RUN_UNDER:-1}" == "1" ]]; then
runfiles="${1}.runfiles"
if [[ -d "${runfiles}" ]]; then
export RUNFILES_DIR="${runfiles}"
if [[ -f "${runfiles}/MANIFEST" ]]; then
export RUNFILES_MANIFEST_FILE="${runfiles}/MANIFEST"
fi
fi
cd "${BUILD_WORKING_DIRECTORY}"
fi
unset SCUFFLE_RUN_UNDER;
exec "${@}"
```
Currently when running pnpm i do `SCUFFLE_RUN_UNDER=0 bazel run @pnpm//:pnpm -- --cwd $PWD dev`
Ideally i should just be able to do
`bazel run @pnpm//:pnpm -- dev`
Contributor guide
Research direction
Start at the @pnpm//:pnpm entry point and read the linked js_run_binary documentation and aspect_rules_js README about running Node.js programs. Compare the current behavior with the custom run_under script and the desired `bazel run @pnpm//:pnpm -- dev` invocation. Done means pnpm can use the requested current directory without requiring an explicit `--cwd`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, shell
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100