bazelbuild / bazelbuild/bazel

ERROR: ...aspect "added more than once"

Open
#21,795 2 comments 3 reactions 0 assignees View on GitHub
team-Core type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

# 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](https://github.com/bazelbuild/bazel/blob/935bd263ec5912469d7d0f0abe54efc071018a32/src/main/java/com/google/devtools/build/lib/packages/AspectsList.java#L418) 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_

Contributor guide

Open the contributing guide

Research direction

Start in src/main/java/com/google/devtools/build/lib/packages/AspectsList.java around lines 418 and 431, then reproduce the behavior with bazel build //my:target --config=my_aspect --config=my_aspect. Compare the duplicate-aspect handling branches and determine the intended result for repeated --aspects entries; done means the behavior is resolved consistently and the reproduction no longer produces the reported error if duplicates are meant to be tolerated.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.