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

Failing run_js_binary example #108

Closed
wants to merge 1 commit into from
Closed

Failing run_js_binary example #108

wants to merge 1 commit into from

Conversation

jfirebaugh
Copy link
Contributor

I am not sure whether this is a bug or user error. I'm trying to replace a nodejs_binary + genrule combo with js_binary + run_js_binary, but can't get paths to line up.

$ bazel build //example/run_js_binary:run_copy
INFO: Analyzed target //example/run_js_binary:run_copy (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/john/figma/rules_js/example/run_js_binary/BUILD.bazel:9:14: RunBinary example/run_js_binary/out.txt failed: (Exit 1): _copy_launcher.sh failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/example/run_js_binary/_copy_launcher.sh example/run_js_binary/in.txt bazel-out/darwin-fastbuild/bin/example/run_js_binary/out.txt

Use --sandbox_debug to see verbose messages from the sandbox
example/run_js_binary/in.txt -> bazel-out/darwin-fastbuild/bin/example/run_js_binary/out.txt
node:internal/fs/utils:344
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'bazel-out/darwin-fastbuild/bin/example/run_js_binary/out.txt'
    at Object.openSync (node:fs:585:3)
    at Object.writeFileSync (node:fs:2153:35)
    at Object.<anonymous> (/private/var/tmp/_bazel_johnfirebaugh/3cc5be9735d30b6128426fd19d172550/execroot/aspect_rules_js/bazel-out/darwin-opt-exec-2B5CBBC6/bin/example/run_js_binary/copy.js:4:4)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'bazel-out/darwin-fastbuild/bin/example/run_js_binary/out.txt'
}
Target //example/run_js_binary:run_copy failed to build

@alexeagle
Copy link
Member

This one is indeed user error, because you're putting paths in the args.

Bazel's implementation of $(location) (and $(execpath) and $(rootpath) which they recommend using instead) will put a bazel-out/[arch]/bin on the front of generated file paths, because they assume the working directory will be the workspace root in the source tree. That assumption is wrong in rules_js.

One workaround is to always put ../../../ in front of such paths, which fixes this PR. You can see that in //examples:bin9 as well.
We've also talked about maybe changing the implementation of these helpers when passed to run_js_binary, or supplying alternative helpers.

@jfirebaugh
Copy link
Contributor Author

Got it, thanks!

We've also talked about maybe changing the implementation of these helpers when passed to run_js_binary, or supplying alternative helpers.

I would support either of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants