ERROR: ...aspect "added more than once"
Description of the bug:
Given a .bazelrc entry build:my_aspect --aspects=//tools:my_aspect:my_aspect.bzl%my_aspect --output_groups=+my_aspect_files
When passing --config=my_aspect on the command line, if it appears more than once, perhaps via user.bazelrc, or via multiple configs, the following error occurs:
ERROR: aspect //tools/my_aspect:my_aspect.bzl%my_aspect added more than once
It seems this should not happen or there should be a way to allow it to happen without error.
It appears to happen because of this line:
https://github.com/bazelbuild/bazel/blob/935bd263ec5912469d7d0f0abe54efc071018a32/src/main/java/com/google/devtools/build/lib/packages/AspectsList.java#L431
And from reading the code locally I didn't see an obvious work around.
Ask
Given that the other branch of that same if simply ignores a duplicated aspect:
- Is there a reason this needs to be an error rather than just a warning?
Details
Which category does this issue belong to?
Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
bazel build //my:target --config=my_aspect --config=my_aspect
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
release 6.2.0-lat7
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Don't know
Have you found anything relevant by searching the web?
"added more than once" does not appear in any of those places.
Any other information, logs, or outputs that you want to share?
No response
Any workaround better than trying to parse .bazelrc files and decide whether to add the aspect or not?
AFAICT, this could simply be changed to return false instead of throwing an error. Not sure if there's a non-obvious reason this should be an error.
I just created #22926 to address this. Not sure if it's welcome, but want if so, want to make it as easy as possible to happen.