bazelbuild / bazelbuild/bazel

Repository not re-evaluated when BUILD file referenced by repository is removed

Open
#27,537 0 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:

Bazel does not seem to be re-fetching / re-evaluating repositories if a `BUILD.bazel` for a label denoting the package boundary is removed while still being referenced by the repository.

See the repro code below for an example.

I expected to see an error like

```
BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
```

but instead the build passes no problem. I am only able to force the error after running `bazel clean --expunge --async`.

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

https://github.com/lamcw/bazel-repo-invalidate-repro

Run the following in the above Git repository:

```console
$ bazel build @gtest//:readme # builds ok
$ rm -f third_party/gtest/BUILD.bazel
$ bazel build @gtest//:readme # should fail, but builds ok
```

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

MacOS

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

release 8.4.2

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

```text

```

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

I have yet to run a bisect, but this is reproducible on Bazel 7.7.0 and 7.6.2

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

_No response_

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

Inspecting `$(bazel info output_base)/java.log`, I can see that the Bazel server detects changes in the relevant BUILD.bazel file, but somehow decided not to re-evaluate the repository.

```console
$ grep 'BUILD.bazel' $(bazel info output_base)/java.log
251105 08:39:40.285:I 172 [com.google.devtools.build.lib.skyframe.SkyframeExecutor.logDiffInfo] DiffAwareness found 1 modified source files and directory listings for /Users/thomaslam/work/bazel-repo-invalidate-repro: [/Users/thomaslam/work/bazel-repo-invalidate-repro]/[third_party/gtest/BUILD.bazel]
```

Contributor guide

Open the contributing guide

Research direction

Start with the minimal repository at https://github.com/lamcw/bazel-repo-invalidate-repro and reproduce the two bazel build commands around removing third_party/gtest/BUILD.bazel. Then inspect the output-base java.log entry showing the detected change and trace why the repository is not re-evaluated. Done means the second build reports the missing BUILD file without requiring bazel clean --expunge --async.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos
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.