zig
zig copied to clipboard
build: probabilistic inconsistent cache state on MacOS
Zig Version
0.13.0-dev.3+dddddcffd
OS: macOS 14.4.1
Steps to Reproduce and Observed Behavior
zig init
zig build
On an empty project the build errors out with a message like:
install
└─ install harley
└─ zig build-lib harley Debug native 1 errors
error: failed to rename compilation results ('/Users/mitiko/Documents/Compression/harley/zig-cache/tmp/5d25342d02e7feb3') into local cache ('/Users/mitiko/Documents/Compression/harley/zig-cache/o/ce78af496c76221b67d202951678cae3'): Unexpected
error: the following command failed with 1 compilation errors:
/Users/mitiko/.zvm/master/zig build-lib -ODebug -Mroot=/Users/mitiko/Documents/Compression/harley/src/root.zig --cache-dir /Users/mitiko/Documents/Compression/harley/zig-cache --global-cache-dir /Users/mitiko/.cache/zig --name harley -static --listen=-
install
└─ install harley
└─ zig build-exe harley Debug native 1 errors
error: failed to rename compilation results ('/Users/mitiko/Documents/Compression/harley/zig-cache/tmp/a7d9ffbd9621177d') into local cache ('/Users/mitiko/Documents/Compression/harley/zig-cache/o/7c66ffb5a3e7200bb814453bc8eb7e62'): Unexpected
error: the following command failed with 1 compilation errors:
/Users/mitiko/.zvm/master/zig build-exe -ODebug -Mroot=/Users/mitiko/Documents/Compression/harley/src/main.zig --cache-dir /Users/mitiko/Documents/Compression/harley/zig-cache --global-cache-dir /Users/mitiko/.cache/zig --name harley --listen=-
Build Summary: 0/5 steps succeeded; 2 failed (disable with --summary none)
install transitive failure
├─ install harley transitive failure
│ └─ zig build-lib harley Debug native 1 errors
└─ install harley transitive failure
└─ zig build-exe harley Debug native 1 errors
error: the following build command failed with exit code 1:
/Users/mitiko/Documents/Compression/harley/zig-cache/o/b9b7eb2041cc09bf2d5b9e45691c6ffe/build /Users/mitiko/.zvm/master/zig /Users/mitiko/Documents/Compression/harley /Users/mitiko/Documents/Compression/harley/zig-cache /Users/mitiko/.cache/zig --seed 0xccce38c2 -Zf2790a3be8ae49c3
Sometimes it fails to build just the library, sometimes it fails on both the library and the executable. Clearing the cache with rm -rf zig-cache zig-out
and rebuilding sometimes succeeds though.
Subsequent zig build
and zig build run
will give me (even after a successful initial build):
error: Unexpected
Related issues:
- https://github.com/ziglang/zig/issues/18459
- https://github.com/ziglang/zig/issues/18627
These seem to be targeting Windows only, so I chose to open a new issue instead.
Expected Behavior
I expect the build to pass on an empty project.
Is there a chance this could be related to #17342, or even what causes the behavior of that issue? I made it a while back and thought it was related to the cache, maybe look at it and see if that helps.
Oh, wow, that's most likely it. I was never able to reproduce this in /tmp/repro
, and the only difference is I'm not backing up /tmp
to iCloud.
I am wondering if there's a better way to exclude folders from being backed up, instead of suffixing with .nosync
.
If you want your Zig projects in iCloud, I don't think there's a better way currently. My own workaround has been not uploading them to iCloud and instead using a completely local directory that iCloud doesn't touch (~/dev/
), and Zig has worked completely fine there since there isn't a remote resource it has to use.
Maybe this is also connected to Zig's async
/await
development, but I'm not sure. Hopefully the completely local directory workaround helps!
Yeah, thanks! I went local as well and haven't had problems since. I'll go ahead and close this one as it doesn't seem like a problem solvable by the compiler? That said, I've never had similar issues with Rust, maybe the caching system there never does moves?