Expectation: Zig should be able to handle any type of file in the repository.
Bug Report
If a project contains symbolic links (symlinks), it cannot be successfully fetched by the zig fetch command.
Here is a minimal example: a project that includes a symlink pointing to the README file. When you attempt to fetch it with zig fetch, the following error occurs:
error: unable to hash 'README': Unexpected
This issue may prove fatal to compatibility with the C/C++ ecosystem.
lib/std.Io.zig
pub const UnexpectedError = error{
/// The Operating System returned an undocumented error code.
///
/// This error is in theory not possible, but it would be better
/// to handle this error than to invoke undefined behavior.
///
/// When this error code is observed, it usually means the Zig Standard
/// Library needs a small patch to add the error code to the error set for
/// the respective function.
Unexpected,
};
This is a known issue and the current proposed fix is to introduce a .symlink_behavior = (.keep|.omit|.copy) option to build.zig.zon that would let you specify how to handle symlinks when unpacking dependencies.
Edit: Although the linked issues only concern fetching what is already declared in build.zig.zon, not the zig fetch command itself. But I would expect that the proposed fix also implies fixing the zig fetch command.
No, it hasn’t been implemented yet. The “urgent” milestone means that the issue is in the backlog and should be worked on when given time, but that it’s not blocking a tagged release and less prioritized than issues tagged as 0.17, 0.18, etc.
However, I see now that the status code you got was PENDING which normally shouldn’t occur, so this might be a bug in the package fetching implementation on Windows. error.Unexpected should never be surfaced to users when using I/O APIs correctly, so you might want to consider filing a bug report stating that the expected behavior is to return an error that clearly communicates that symlinks are unsupported.