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

fix: ensure BAZEL_NODE_RUNFILES_HELPER & BAZEL_NODE_PATCH_REQUIRE are absolute #1634

Merged

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Feb 13, 2020

This is for using BAZEL_NODE_RUNFILES_HELPER in bazel build when there are no runfiles and with a tool that does not support workers. The cwd is a path such as: /private/var/tmp/_bazel_greg/35306ad70b8da8f7bc31590523de35c0/sandbox/darwin-sandbox/18/execroot/build_bazel_rules_nodejs.

export BAZEL_NODE_RUNFILES_HELPER=$(rlocation "build_bazel_rules_nodejs/internal/linker/runfiles_helper.js")

resolves to /Users/greg/google/rules_nodejs/internal/linker/runfiles_helper.js when workers are on as there is no sandbox (such as ts_library).

&

resolves to bazel-out/host/bin/external/build_bazel_rules_typescript/internal/tsc_wrapped_bin.sh.runfiles/build_bazel_rules_nodejs/internal/linker/runfiles_helper.js when workers are off as there is a sandbox

The latter is a relative path to the CWD and won't work in a require() statement unless joined with the CWD.

This PR adds the CWD in the launcher.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

… absolute

```
export BAZEL_NODE_RUNFILES_HELPER=$(rlocation "build_bazel_rules_nodejs/internal/linker/runfiles_helper.js")
```

resolves to `/Users/greg/google/rules_nodejs/internal/linker/runfiles_helper.js` when workers are on as there is no sandbox

&

resolves to `bazel-out/host/bin/external/build_bazel_rules_typescript/internal/tsc_wrapped_bin.sh.runfiles/build_bazel_rules_nodejs/internal/linker/runfiles_helper.js` when workers are off as there is a sandbox

The latter is a relative path and won't work in a require() statement unless joined with the CWD.

This commit adds the CWD in the launcher.
const args = process.argv.slice(2);
const outfile = args.shift();
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
const golden =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line looks strange, lots of spaces for some reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang format did that for line length I think

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

Successfully merging this pull request may close these issues.

4 participants