-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Starlark runfiles merging silently drops --legacy_external_runfiles external runfiles links #17415
Comments
Oh, I forgot add: IMHO this should just be left alone. The goal is to switch to --legacy_external_runfiles=false, right? This bug effectively means that Starlark code is effectively acting that way already -- in order to not trigger this bug, you have to never merge with another runfiles through Starlark. It's probably just native rules being rewritten to Starlark that are affected, since they were able to use Java APIs that propagated legacy_external_runfiles. |
This was found by way of the upb downstream tests, which currently rely on the legacy external runfiles format for runfiles (this is when files that come from other repositories are put in `$runfilesRoot/$mainRepo/external/$otherRepo`). What happens is a regular `runfiles.merge(other)` call will, under the hood, create a new Runfiles.Builder object with legacyExternalRunfiles=false, thus losing the value from the flag. To fix, we just have to create a builder with the value from the flag so that the created Runfiles object keeps it. Workaround for #17415 PiperOrigin-RevId: 507503578 Change-Id: I961f50f73ae1ee9980da92eff1b333cbc3b82104
This was found by way of the upb downstream tests, which currently rely on the legacy external runfiles format for runfiles (this is when files that come from other repositories are put in `$runfilesRoot/$mainRepo/external/$otherRepo`). What happens is a regular `runfiles.merge(other)` call will, under the hood, create a new Runfiles.Builder object with legacyExternalRunfiles=false, thus losing the value from the flag. To fix, we just have to create a builder with the value from the flag so that the created Runfiles object keeps it. Workaround for #17415 PiperOrigin-RevId: 507503578 Change-Id: I961f50f73ae1ee9980da92eff1b333cbc3b82104
P4, I share the opinion to leave this alone :) |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
The flag has been flipped and this "bug" probably made that easier. :-) |
(Mostly filing this for posterity, as its a subtle behavior change that can be hard to debug)
Description of the bug:
When merging runfiles with the Starlark APIs (e.g.
ctx.runfiles().merge()
orctx.runfiles().merge_all()
), certain invocations will silently drop the "external/" paths that --legacy_external_runfiles (default true) creates.Looking at Runfiles.java, I see legacyExternalRunfiles is hard-coded to false in various spots.
I think the generalized case is: merging any two non-empty runfiles will drop legacyExternalRunfiles. This is because the Runfiles.Builder ctor argument legacyExternalRunfiles determines the final value (i.e. any intermediate
Runfiles objects being merged in don't have their legacyExternalRunfiles value considered).
The Runfiles.merge() logic is this:
The Runfiles.mergeAll logic is harder to follow, but I think basically the same: all its builder calls force legacyExternalRunfiles=false.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Expected: the find command lists
external/repo2/r2.txt
Actual: It does not
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?dev
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.bazel build //src:bazel-dev
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Have you found anything relevant by searching the web?
flag flip for legacy_external_runfiles: #12821
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: