Very often, engineers I support ask me how they can inspect what Bazel thinks has changed between builds. While it’s true that they could generate execution logs and compare them, they often don’t have those enabled, and diffing the logs can be tricky given how large they can get.
Yes, there’s the BuildBuddy CLI, which can help with that, but there’s another way to peek into Bazel’s state and see which files Bazel detected as changed when deciding what needs to be re-evaluated.
Enter DiffAwareness
This is a neat trick for inspecting Bazel’s server log to see what changes Bazel detected.
After running a build, we can use grep, rg, or any other tool to inspect the log.
For example:
bazel build //:app
Now, let’s say the build has finished. Whether Bazel actually re-ran any actions (or invoked the compiler) is a different question. We can inspect which file changes Bazel detected by running:
rg 'DiffAwareness found' "$(bazel info server_log)"
This will show the changes Bazel detected since the previous evaluation, with the log listing at most 10 individual changed paths per diff-awareness event.
Here, we’re simply using rg to search Bazel’s server log. Nothing fancy.
One important distinction: these are files Bazel detected as changed, not necessarily files that caused an action to re-run. Bazel may still determine that no actions need to be executed.
Conclusion
This isn’t something I use all that much, and to be frank, I don’t find it particularly useful day to day. But it’s nice to have in the toolbox when debugging builds, investigating unexpected rebuilds, or even debugging Bazel itself.