bazelbuild / bazelbuild/bazel

Build graph invalidation with custom flags from external repositories

Open
#17,853 6 comments 0 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:

To fix issues with rules_docker transitions leaking into our own transitions and multiplicating the number of different configurations, we have added `build --@io_bazel_rules_docker//transitions:enable=no` to our .bazelrc, as per https://github.com/bazelbuild/rules_docker/pull/2068

That works, but introduced a subtle and hard to track issue where running some bazel commands like cquery, dump or config would in some cases invalidate large parts of the daemon's build graph. I started investigating [several months ago](https://bazelbuild.slack.com/archives/CA31HN1T3/p1655992434086069), and saw a breakthrough only [recently](https://bazelbuild.slack.com/archives/CA31HN1T3/p1679408139711459).

It seems that these less frequently used commands have trouble taking that value into account. There is also some history with workspace label prefixes in custom build flags. See in general https://github.com/bazelbuild/bazel/issues/11128 and https://github.com/bazelbuild/bazel/issues/9177 for historical, somewhat related issues.

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

This works for me, be I still have to provide a minimal repo where it works:

```
echo "build --@io_bazel_rules_docker//transitions:enable=no" >> .bazelrc
# Get a proper build graph in cache
bazel build //...
# List current configurations
bazel config
# Invalidate the cache with a command that does no understand/use the above flag
bazel info output_path
# Observe that the set of cached configurations has changed
bazel config
```

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

Ubuntu Linux 20.04 (+nix)

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

release 6.0.0- (@non-git)

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

Its bazel 6.0.0 from nixpkgs.

### 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?

See description above

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

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.