bazelbuild / bazelbuild/bazel

Repository rule reading the file never reads it again, despite the file changed and rule re-run.

Open
#14,453 2 comments 0 reactions 1 assignee Claimed by @Wyverald View on GitHub
not stale P2 team-ExternalDeps type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the problem / feature request:

If repository rule reads the file (with `repository_ctx.read`) subsequent rule executions don't try to read the file again, but assume previous values.

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

I have created compact repro [here](https://github.com/Bazel-snippets/read_file_repo_rule).
Command to run `bazel build do_nothing`
Test file `test_file.txt` does not exist and the rule correctly reports it.
Now create `test_file.txt` at the workspace root and run `bazel build do_nothing` - it still reports that the file does not exist!
This happens until Bazel is shutdown. The next run reports the file properly.

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

Linux, Mac, Windows

### What's the output of `bazel info release`?

4.2.1

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.