bazelbuild / bazelbuild/bazel

Use of `--` in rc files interferes with parsing of other lines giving hard to predict results.

Open
#17,421 6 comments 0 reactions 0 assignees View on GitHub
P3 team-Core type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the bug:

See my comment here: https://github.com/bazelbuild/bazel/issues/7116

Placing a line like `build --some_flag -- //some:target` in a `.bazelrc` file seems to have the side effect of causing anything from other `.bazelrc` files that expands after it to be treated a a target.

While this is not exactly unexpected, it's likely not of any practical value and also likely to cause results the average uses finds very unpredictable.

-----

What I would expect to get is that the semantic of `--` (i.e. treat everything else as a target) would apply independently to each "part" of the composed command line. This seems to work at least partial as I can't seem to get `--` on the actual command line to interact with flags from `.bazelrc` or the other way around. Getting that same sort of "isolation" between different rc file lines is what I'd like to get.

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a `.bazelrc`:
```
build --
build --not_a_target
```

run `bazel build ...`

result:

```
ERROR: Skipping '-not_a_target': no such target '//:-not_a_target': target '-not_a_target' not declared in [...]
WARNING: Target pattern parsing failed.
ERROR: no such target '//:-not_a_target': target '-not_a_target' not declared in [...]
```

### Which operating system are you running Bazel on?

linux

### What is the output of `bazel info release`?

release: release 6.0.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with the two-line .bazelrc example and `bazel build ...` described in the issue. Trace how separate .bazelrc lines are composed and how `--` changes target parsing; done means each rc-file line applies its `--` semantics independently, without later rc-file content being treated as targets.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.