bazelbuild / bazelbuild/rules_rust
Building with --@rules_rust//:error_format flag invalidates Bazel cache
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Running `bazel build ` followed by `bazel build --error-format=json ` will discard analysis cache and action cache:
(from build command log)
```
INFO: Build option --@rules_rust//:error_format has changed, discarding analysis cache.
```
(From bazel explain log)
```
Executing action 'Compiling Rust (without process_wrapper) rlib tinyjson (4 files)': action command has changed.
New action: Compiling Rust (without process_wrapper) rlib tinyjson (4 files)
```
A consecutive `bazel build ` will run without action cache as well.
This behavior isn't really surprising, as described in several Bazel tickets - i.e https://github.com/bazelbuild/bazel/issues/13591
but as Cargo manages to re emit errors in json format without recompiling the project, I seek your advice.
In our use case we setup Rust analyzer to run a custom cargo check command that uses the `--error-format=json` flag. This results in consecutive builds with and without this flag. We edit code, Rust analyzer runs `bazel build --error-format=json`, than we run the tests without the `--error-format=json` flag. This results in a very cache inefficient workflow
Contributor guide
Assessment
This issue has not been assessed yet.