WindowsmacOSLinux

Where Does Zig Store Cache and Packages?

Zig global cache plus build cache inside projects on Windows, macOS and Linux.

Last updated

Zig keeps a global cache for packages plus per project zig-cache and zig-out folders. Global location follows ZIG_CACHE_DIR or the OS cache home.

Caches are disposable. Source plus build.zig are the truth. Delete caches to fix weird build states; the compiler refetches pinned deps.

Where Zig stores this, by platform

Windows
%LOCALAPPDATA%\zig\

Global cache home (override with ZIG_CACHE_DIR). Project cache is [ProjectDir]\.zig-cache with output in zig-out. Run zig env to confirm.

macOS
~/Library/Caches/zig/

Default global cache on Mac. Project folders stay beside build.zig. Keep build.zig plus sources in git; ignore zig-cache and zig-out.

Linux
~/.cache/zig/

Follows XDG cache home (or ZIG_CACHE_DIR). Same project layout. Exclude zig-cache and zig-out from version control.

Frequently asked questions

Where is the Zig package cache?

Under the global cache dir above in p subfolders, keyed by hash. Deleting it forces refetch of build.zig.zon deps on next build.

Which Zig folders belong in git?

Commit build.zig, build.zig.zon and sources. Ignore .zig-cache and zig-out. A fresh clone plus build reproduces outputs.

Notice an outdated path? Let us know.