Bazel Caching Without Rebuilding Everything: Disk Cache, Remote Cache, and Hermeticity
Reuse Bazel action outputs across machines and CI runs with --disk_cache and --remote_cache, but only if your actions stay hermetic.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Reuse Bazel action outputs across machines and CI runs with --disk_cache and --remote_cache, but only if your actions stay hermetic.
A step‑by‑step architecture note for adding a read‑write remote Bazel cache to CI, covering requirements, minimal design, trust boundaries, ops checks, failure modes, and when to evolve the design.
Learn how Bazel's action graph caching and hermetic sandboxing give truly incremental builds, see a concrete Java example, and understand the trade-offs before adopting it in your monorepo.
Cache key behavior with environment variables Bazel's default action key calculation omits most environment variables. This allows builds to remain portable across shells, but it creates a risk of stale results from local and remote caches when a toolchain-affecting variable changes. The experimental flag --experimental_strict_action_env forces Bazel to incl
When Bazel retries a failed action under a remote strategy, it redirects each attempt to a distinct temporary sandbox and only moves the successful outputs to the final output tree. This prevents duplicate files from appearing, but it does not guarantee that the action’s side effects—such as updates to external services or shared files—are harmless if repeat
Trade-off: Local Path Shortcut vs Reproducible Fetch A workspace declares a private dependency that exists on developer machines at a fixed absolute path. Using local_repository in WORKSPACE (or MODULE.bazel with local_path_override ) lets the build succeed locally without network access. In production CI and remote execution, the same absolute path does not