LinuxmacOS

Where Does Bazel Keep Its Build Cache?

Where Bazel keeps its output base and action cache under .cache/bazel, and the info commands that reveal them.

Last updated

Bazel isolates every workspace under ~/.cache/bazel/_bazel_<user>/<workspace-hash>: symlinks like bazel-bin and bazel-out point into it, while the action cache deduplicates work across builds. One user, many workspaces, zero cross talk.

The hash suffix means each checkout gets its own tree, so disk use multiplies with clones. bazel info output_base prints the live one; --disk_cache aims shared artifacts at a common directory for teams. Repository downloads cache separately and are the part worth keeping across wipes.

Where Bazel stores this, by platform

Linux
~/.cache/bazel

Respects $XDG_CACHE_HOME. Each workspace hashes to its own subtree. Inspect with bazel info / bazel info output_base. Clean per workspace with bazel clean.

macOS
~/.cache/bazel

Same layout and info commands as Linux. Xcode adjacent builds share the cache fine; concurrent bazel servers coordinate through lockfiles.

Frequently asked questions

How do I find my exact Bazel directories?

Run bazel info to print output_base, execution_root and friends for the current workspace. Every path question about Bazel ends there: the flags and startup options move things more often than docs suggest.

How do I reclaim disk from Bazel safely?

Run bazel clean for one workspace (drops its outputs, keeps shared cache) or bazel clean --expunge for the full output base. The repository cache (--repository_cache) survives both and is the expensive download to preserve. Disk pressure usually means many workspaces, not one big cache.

Notice an outdated path? Let us know.