How to fix the lost zig/o/xxx files

I deleted all files in the directory $global_cache_dir/o, and i can not build any zig code now.

The error is

❯ zig test .\time.zig
error: lld-link: could not open '...\AppData\Local\zig\o\a8b8c9f04029aad98535580bca73a2a1\ntdll.lib': No such file or directory
error: lld-link: could not open '...\AppData\Local\zig\o\327fcb54349fb00a73e2405302ebd187\kernel32.lib': No such file or directo

BTW, I’d like to know which cache directories can be cleaned safely or
is there any documentation to tell me the purpose of each cache directory?

Remove the entire zig global cache directory to clear the entire cache.

You can get the zig global cache with:
zig env | jq -r .global_cache_dir
Normally that is the ...\AppData\Local\zig.

3 Likes