Zig fetch error : unable to rename temporary directory

Just got this error from zig fetch:

error: unable to rename temporary directory

Never experienced this before. zig fetch otherwise works fine for me.

Background: wanted to use a library I forked; here’s the full command + output:

zig fetch https://github.com/FObersteiner/zigserial/archive/refs/tags/v0.0.1.tar.gz
error: unable to rename temporary directory '/home/[user]/.cache/zig/tmp/a61345c038aa0d65' into package cache directory '/home/[user]/.cache/zig/p/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': FileNotFound

I solved the issue by manually creating '/home/[user]/.cache/zig/p/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', copy-pasting the library code there and setting 1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 as the library hash in the .zon file of the application that wants to use the lib.

While that works, it’s kind of cumbersome and I was wondering what mischief I might have created to trigger this error?

It seems like cache corruption. I believe it is better to delete the entire $HOME/.cache/zig to make a clean start.

That’s what I through too, but that didn’t change anything :confused:

Edit: gave this another try on another, freshly booted machine: same result. For context, I’m running this on a debian Linux desktop machine, nothing special.

  • library in question: https://github.com/FObersteiner/zigserial (fork of another repo, which I modified to have a zon file etc.)
  • program that’s using the lib: https://codeberg.org/FObersteiner/fun_in_series (a simple serial port reader CLI) .
  • besides the fetch command (see OP), zig build test or zig build run triggers the issue if you just clone the repo without modifying the cache as described in the OP. That happens with Zig 0.12, 0.13 and master.

The problem is that zigserial package does not export build.zig and build.zig.zon.
Just add the files in the zigserial build.zig.zon paths.

1 Like

hah! I knew I missed something ^^ Thanks a lot. I that light, the error seems… kind of misleading.

2 Likes