Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to bazel run a js_binary() on Windows #481

Open
lukasoyen opened this issue Sep 29, 2022 · 0 comments
Open

Unable to bazel run a js_binary() on Windows #481

lukasoyen opened this issue Sep 29, 2022 · 0 comments
Labels
bug Something isn't working help wanted Aspect isn't prioritizing this, but the community could windows Specific to Windows

Comments

@lukasoyen
Copy link

Trying to bazel run a binary created with js_binary() (using 86b7aaa) on Windows fails with the following error:

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.

This bazel run is successfull on Linux/Mac. A js_run_binary() works.

I would guess the error is due to

if [[ "$PWD" == *"/bazel-out/"* ]]; then
evaluating to false in that bazel run context. Adding a env = {"BAZEL_BINDIR":"$(BINDIR)"} to the js_binary() produces:

C:/users/XXX/XXX/hlezeung/execroot/XXX/bazel-out/x64_windows-opt/bin/XXX/dependencies/javascript/license_checker.sh: line 299: cd: bazel-out/x64_windows-opt/bin: No such file or directory

While looking at the code I thought JS_BINARY__BINDIR might be relevant here, but it seems unused except for the logging statement in

logf_debug "binary target BINDIR %s" "${JS_BINARY__BINDIR:-}"

@cgrindel cgrindel added bug Something isn't working discussion needed Discussion required to progress further help wanted Aspect isn't prioritizing this, but the community could and removed discussion needed Discussion required to progress further labels Oct 3, 2022
@gregmagolan gregmagolan added the windows Specific to Windows label Feb 4, 2023
@gregmagolan gregmagolan moved this to 📋 Backlog in Open Source Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Aspect isn't prioritizing this, but the community could windows Specific to Windows
Projects
No open projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants