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(builtin): always symlink node_modules at execroot/my_wksp/node_modules even when running in runfiles #1805

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Apr 8, 2020

Fixes #1781.

Under runfiles, the linker should symlink node_modules at execroot/my_wksp so that when there are no runfiles (default on Windows) and scripts run out of execroot/my_wksp they can resolve node_modules with standard node_module resolution.

Also, restore BAZEL_WORKSPACE name environment variable. The optimization of deriving the workspace name from the path does not work on RBE. While we can derive the workspace from the pwd when running locally because it is in the execroot path execroot/my_wksp, on RBE the execroot/my_wksp path is reduced a path such as /w/f/b so the workspace name is obfuscated from the path. So we provide the workspace name here as an environment variable avaiable to all actions for the runfiles helpers to use.

@buildsize
Copy link

buildsize bot commented Apr 8, 2020

File name Previous Size New Size Change
release.tar.gz 967.47 KB 968.29 KB 841 bytes (0%)

@gregmagolan
Copy link
Collaborator Author

Noting here that I tested manually on my Windows laptop to verify that this resolves #1781.

@gregmagolan gregmagolan force-pushed the linker_at_execroot branch 3 times, most recently from bad474f to 8c7303d Compare April 9, 2020 00:17
Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

super cool

internal/linker/link_node_modules.ts Outdated Show resolved Hide resolved
internal/linker/link_node_modules.ts Outdated Show resolved Hide resolved
const startCwd = process.cwd().replace(/\\/g, '/');
log_verbose('startCwd', startCwd);

// We can derive if the process is being run in the execroot if there is a bazel-out folder.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a different mechanism than in your other PR where you check for execroot in the path. Is one better than the other?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Looking for execroot basename will not work in RBE. I'll fix up the other PR. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, the other PR needs to change once it is rebased on top of this one after it lands since the location of the linker node_modules has moved here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#1800 for future reference

…odules` even when running in runfiles

Under runfiles, the linker should symlink node_modules at `execroot/my_wksp` so that when there are no runfiles (default on Windows) and scripts run out of `execroot/my_wksp` they can resolve node_modules with standard node_module resolution

Also, restore BAZEL_WORKSPACE name environment variable. The optimization of deriving the workspace name from the path does not work on RBE. While we can derive the workspace from the pwd when running locally because it is in the execroot path `execroot/my_wksp`, on RBE the `execroot/my_wksp` path is reduced a path such as `/w/f/b` so the workspace name is obfuscated from the path. So we provide the workspace name here as an environment variable avaiable to all actions for the runfiles helpers to use.
@gregmagolan gregmagolan merged commit 5c2f6c1 into bazel-contrib:master Apr 9, 2020
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1803 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit to gregmagolan/rules_nodejs that referenced this pull request Apr 9, 2020
Issue bazel-contrib#1813 was fixed by bazel-contrib#1800 which is already landed. bazel-contrib#1805 also fixes via a different mechanism and will also land soon.
gregmagolan added a commit that referenced this pull request Apr 9, 2020
Issue #1813 was fixed by #1800 which is already landed. #1805 also fixes via a different mechanism and will also land soon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

//internal/pkg_npm/test/linking:test fails on Windows with remote caching enabled
3 participants