rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Building with --@rules_rust//:error_format flag invalidates Bazel cache

Open alexpusch opened this issue 3 years ago • 0 comments

Running bazel build <target> followed by bazel build --error-format=json <target> 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 <target> 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

alexpusch avatar Aug 27 '22 18:08 alexpusch