You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@ and @workspacename considered different repositories #3115
Description of the problem / feature request / question:
Bazel evaluates the same Skylark file multiple times if it is loaded with a local path and an absolute path. This creates problems for rules, since everything gets defined twice. It is particularly problematic for named providers, since the duplicate definitions are neither equivalent nor compatible.
We ran into this issue when trying to migrate rules_go to use named providers. We load our .bzl files with local labels in our own repository, but repositories that depend on ours load using absolute labels, which causes errors.
Bazel should not evaluate the same .bzl file in the same repository more than once.
If possible, provide a minimal example to reproduce the problem:
This is acutely annoying for providers, since it both breaks things, and gives bad diagnostics ("does not have mandatory providers Foo" even though it has "Foo", just a different foo). If it is difficult to fix, it might be worth at least failing-fast in the meantime, even if only for providers.
@laurentlb this P1 will celebrate anniversary soon.
Is there an update here? I'm not hitting this exact issue but I think I have an adjacent problem (same target gets evaluated twice, once as external and once as internal)
Interestingly, the issue is not fully solved by (the current implementation of) --incompatible_remap_main_repo (#7130). Consider the following test cases
The first test passes, whereas the second fails in the build with remapping; interestingly enough, that command passes if we build //:y instead of @foo//:y.
@ittaiz Klaus is no longer working at Google or on Bazel. As far as I know there are open issues for a few related problems, if there are any more, can you file them separately?
Activity
Absoulte paths for load statements (#503)
jwnimmer-tri commentedon Nov 9, 2017
This is acutely annoying for providers, since it both breaks things, and gives bad diagnostics ("does not have mandatory providers Foo" even though it has "Foo", just a different foo). If it is difficult to fix, it might be worth at least failing-fast in the meantime, even if only for providers.
ittaiz commentedon May 16, 2018
@laurentlb this P1 will celebrate anniversary soon.
Is there an update here? I'm not hitting this exact issue but I think I have an adjacent problem (same target gets evaluated twice, once as external and once as internal)
laurentlb commentedon May 16, 2018
Klaus, are you aware of this issue?
I don't know exactly at which level we need to fix this (so assigning to both Jon and Klaus).
brandjon commentedon May 25, 2018
FYI if it's a local and absolute path within the same repo ("//" vs ":") it doesn't reproduce, so I believe it has to be a repository-specific issue.
54 remaining items
sergiocampama commentedon May 9, 2019
what about
bazel/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
Line 504 in 9a005f7
sergiocampama commentedon May 9, 2019
I'm seeing the exact provider missing error described in this issue in https://buildkite.com/bazel/rules-apple-darwin/builds/827#5ef4767f-56d7-48b6-a07e-992c9fa26db9
katre commentedon May 9, 2019
The flag is now
--incompatible_remap_main_repo: https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java;l=503?q=main_repoIt was scheduled to be flipped but there was missing functionality, and it was not made default in 0.26.
See the tracking issue: #7130.
sergiocampama commentedon May 9, 2019
Shouldn't this issue be open then until the incompatible flag is flipped?
added --experimental_remap_main_repo=true to solve non cannonical wor…
Change all loads of bzl_library to have the absolute repository
aehlig commentedon Aug 23, 2019
Interestingly, the issue is not fully solved by (the current implementation of)
--incompatible_remap_main_repo(#7130). Consider the following test casesThe first test passes, whereas the second fails in the build with remapping; interestingly enough, that command passes if we build
//:yinstead of@foo//:y.Also for default attributes correctly convert strings to labels
aehlig commentedon Dec 3, 2019
#7130 is flipped now.
ittaiz commentedon Jul 20, 2020
@aehlig if there are test cases that are failing with the flag on, shouldn't they be fixed?
katre commentedon Jul 20, 2020
@ittaiz Klaus is no longer working at Google or on Bazel. As far as I know there are open issues for a few related problems, if there are any more, can you file them separately?
ittaiz commentedon Jul 20, 2020
Didn't know that. Will do, thanks.
Minor tidying-up of workspace-relative vs absolute labels.