Skip to content

build: fix bazel run invocations of js_binary/js_test #30119

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devversion
Copy link
Member

After throrough investigation and lots of time spent, I figured out why the fs patch didn't resolve paths within the .runfiles directory.

The .runfiles directory of e.g. a js_binary (with bazel run) does have symlinks for e.g. node_modules/verdaccio point to the execroot directly via an absolute symlink.

This is weird because in other projects there are relative symlinks to the store (this is important for the sandbox escaping FS patches)), as otherwise the dereferencing is blocked/prevented and we'd never resolve into a store directory— preventing transitive deps from being properly resolved.

After figuring this out, I've tracked down the Bazel issue and found a fix: bazelbuild/bazel@51d7a3c

In addition, there seems a related rules_js issue that has the same investigation results:
aspect-build/rules_js#1877

We should try this out, but keep an eye on Firefox and Chromium. Those browser artifacts might contain files with spaces. This is incompatible with the Bazel version we are using, so the inprocess runfile creation was a workaround for this— If we remove that flag, we might cause issues for Mac users.

We have a few options I think:

  1. drop the flag, and hope it doesn't break any runfile generation for browsers. I suspect it won't work...— alternatively try renaming browser files.

  2. keep the flag for now, and temporarily keep the disabled FS patches (needs to be manually specified by users)

  3. do solution (2) but once migration allows it, update to Bazel 7— so that the bug with inprocess resolution is nicely fixed.

I think (3) is a good plan moving forward and we don't need any runfile tricks. In Bazel 8, the runfiles with space issue is also resolved— allowing us to drop the inprocess runfile creation as well (if we want).

@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Apr 16, 2025
@devversion devversion force-pushed the fix-runfile-execution branch from 0361838 to d98ee70 Compare April 16, 2025 18:53
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Apr 16, 2025
@devversion devversion force-pushed the fix-runfile-execution branch from d98ee70 to 3d90a65 Compare April 16, 2025 19:28
After throrough investigation and lots of time spent, I figured out why
the `fs` patch didn't resolve paths within the `.runfiles` directory.

The .runfiles directory of e.g. a js_binary (with bazel run) does have symlinks
for e.g. node_modules/verdaccio point to the execroot directly via an absolute symlink.

This is weird because in other projects there are relative symlinks to
the store (this is important for the sandbox escaping FS patches)), as
otherwise the dereferencing is blocked/prevented and we'd never resolve
into a store directory— preventing transitive deps from being properly
resolved.

After figuring this out, I've tracked down the Bazel issue and found a
fix: bazelbuild/bazel@51d7a3c

In addition, there seems a related `rules_js` issue that has the same
investigation results:
aspect-build/rules_js#1877

We should try this out, but keep an eye on Firefox and Chromium. Those
browser artifacts might contain files with spaces. This is incompatible
with the Bazel version we are using, so the inprocess runfile creation
was a workaround for this— If we remove that flag, we might cause issues
for Mac users.

We have a few options I think:

1. drop the flag, and hope it doesn't break any runfile generation for
  browsers. I suspect it won't work...— alternatively try renaming
  browser files.

2. keep the flag for now, and temporarily keep the disabled FS patches
  (needs to be manually specified by users)

3. do solution (2) but once migration allows it, update to Bazel 7— so
  that the bug with inprocess resolution is nicely fixed.

I think (3) is a good plan moving forward and we don't need any runfile
tricks. In Bazel 8, the runfiles with space issue is also resolved—
allowing us to drop the inprocess runfile creation as well (if we want).
@devversion devversion force-pushed the fix-runfile-execution branch from 3d90a65 to 7bb17d1 Compare April 16, 2025 20:28
@devversion devversion marked this pull request as ready for review April 16, 2025 20:32
@devversion devversion added the action: merge The PR is ready for merge by the caretaker label Apr 16, 2025
@devversion
Copy link
Member Author

@josephperrott FYI: We should try to do the same in the components repo and revert the dev-infra change

@devversion devversion added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: build & ci Related the build and CI infrastructure of the project target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants