Open blorente opened 1 month ago
ctx.read
now watches the contents of files it reads, which is usually what you want.
In this case you clearly don't, so you should be able to get the old behavior back by setting watch = "no"
on the read
call.
Thanks @fmeum for the quick response! If that is the case, I might be misreading the documentation on repository rule evaluation. I think this is the relevant passage:
The content of any file passed to the read(), execute() and similar methods of repository_ctx which is referred to by a label (for example, //mypkg:label.txt but not mypkg/label.txt)
In this case, the repository rule refers to it by a path (link), so I would have expected the rule to not get invalidated. Am I misinterpreting the documentation?
You aren't, the docs are wrong here (they weren't updated with the change).
Cc @Wyverald
Description of the bug:
Starting from Bazel 7.1.0, repository rules that used to be cached and not re-run have started being re-run. This might be a case of Hyrum's Law, but we did rely on this behaviour for caching xcode resolutions internally.
Which category does this issue belong to?
Rules API
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
➜ USE_BAZEL_VERSION='7.0.2' bazel fetch @counter//... INFO: All external dependencies fetched successfully.
➜ USE_BAZEL_VERSION='7.1.0' bazel fetch @counter//... Starting local Bazel server and connecting to it... INFO: Invocation ID: f7704521-eeda-44e8-b609-4c51d37851be DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:5:10: Running counter DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:12:10: Writing counter value 24 ...
➜ USE_BAZEL_VERSION='7.1.0' bazel fetch @counter//... INFO: Invocation ID: 62d9655c-ff33-4d49-9f22-a7a255d42136 DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:5:10: Running counter DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:12:10: Writing counter value 25 ...
➜ USE_BAZEL_VERSION='latest' bazel fetch @counter//... Starting local Bazel server and connecting to it... DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:5:10: Running counter DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:12:10: Writing counter value 26 INFO: All external dependencies for these targets fetched successfully.
➜ USE_BAZEL_VERSION='latest' bazel fetch @counter//... DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:5:10: Running counter DEBUG: /Volumes/code/scratch/scratch/repo-rules/rules.bzl:12:10: Writing counter value 27 INFO: All external dependencies for these targets fetched successfully.