bazelbuild / bazelbuild/bazel

Runfiles tree is not recreated when value of `--enable_runfiles` changes

Open
#9,150 3 comments 1 reaction 0 assignees View on GitHub
not stale P3 team-Rules-Server type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

Or more precisely, the old tree persists even when the target is built with `--enable_runfiles=false`. This causes observable semantic differences when the artifact is sensitive to how the runfiles tree is laid out (or whether it exists at all).

Minimal repro:

```python
# pkg/BUILD
cc_binary(
name = "blah",
srcs = ["blah.cc"],
)
```

```cc
// pkg/blah.cc
#include

int main(int argc, char** argv) {
printf("Hello, world!\n");
return 0;
}
```

```sh
$ bazel clean
...
$ bazel run //pkg:blah
...
$ ls bazel-bin/pkg/blah.runfiles
__main__ MANIFEST

$ bazel run //pkg:blah --enable_runfiles=false
...
$ ls bazel-bin/pkg/blah.runfiles
__main__ MANIFEST

$ bazel clean
...
$ bazel run //pkg:blah --enable_runfiles=false
...
$ ls bazel-bin/pkg/blah.runfiles
MANIFEST
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the two `bazel run //pkg:blah` commands shown, both before and after `bazel clean`, and inspect `bazel-bin/pkg/blah.runfiles`. Start by tracing the runfiles tree creation and invalidation for `--enable_runfiles`; done means changing the flag removes or recreates the tree so stale `__main__` contents do not persist.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.