-
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
Labels in repo rule impls disregard repo_mapping #12963
Comments
Yep, this sounds like the repo remapping not being propagated to all contexts where we construct
Right. Calls to
The same sort of issue exists for BUILD files: Imagine that you call a macro belonging to another repo, passing in a string label that references a repo remapped within the macro's repo. I believe the conceptual solution in that case is supposed to be to convert the string to a Label at the point where you want to lock in the repo mapping. This would mean calling your macro with
No, repo rules need to be able to resolve things from other repos. One case of this is when you generate BUILD/bzl content for your repo that embeds labels of other repos. If you want to resolve them correctly in the face of repo remapping, you need to do that resolution within your own repo rule, then convert it to a string and substitute it into the text that you're generating. Needless to say, it's easy to get this wrong, hence why we want to reevaluate the whole repo renaming model. |
My reading of the code is that the repo mapping is set here:
But Curiously enough, I see the same logic in normal BUILD rules' analysis, so I wonder if we're giving the wrong Label values in rule implementation functions. I don't intend to follow up on this any further until we come to a decision on whether to keep remapping around in its existing form. |
What do you mean? Is there a plan to remove repo mapping? bzlmod makes extensive use of repo mapping to support repo renaming ( |
We discussed offline, but for everyone else: I don't have any particular plan regarding repo remapping other than to study it further to see whether it needs to exist in its current form. If it does, we need to document it better (both to users and within the codebase). |
Not entirely sure whether this is a bug. This happens when you call the
Label("@some_repo//something")
function to construct a label in the impl of a repository rule -- if the repo rule is defined in repo X that maps "some_repo" to "some_other_repo", you'd expect that the label would end up point to "some_other_repo"; but no, "some_repo" is used.This can be a bit surprising, since it differs from the behavior of the
load
statement (understandably since these are resolved at different times). But it can also be surprising if we introduce strict deps for repos.The repro case is a bit hard to construct, but bear with me:
WORKSPACE:
rule_definer/defs.bzl:
Now imagine we had strict deps for repos (as is expected for the external deps overhaul), the repo
@rule_definer
doesn't expect visibility into the repo@data
at all; it just wants@otherdata
(which it unfortunately calls@data
).On the other hand, it's arguable that this is WAI, since we are constructing a repo from the perspective of the root repo (where WORKSPACE lives); but that's inconsistent with
line2
. (Also imagine if either label was not hardcoded in rule_definer/defs.bzl, but provided as an attribute written in WORKSPACE itself -- even more inconsistencies!) Maybe the solution is just to say "when you hardcode labels as is being done here, don't ever hardcode a label with a@repo
part".cc @meteorcloudy @brandjon
The text was updated successfully, but these errors were encountered: