zig
zig copied to clipboard
`zig fetch` on zip archives does not ignore errors for files not in `build.zig.zon` paths
Zig Version
0.15.0-dev.480+49c731805
Steps to Reproduce and Observed Behavior
Ensure the Zig global cache directory is located on a filesystem which does not allow the character : in filenames. On Linux, this can be accomplished by creating and mounting a FAT32 filesystem:
fallocate -l 1G fat32.fs
mkfs.fat -F32 fat32.fs
mkdir fat32.mnt
sudo mount -o rw,umask=0000 fat32.fs fat32.mnt
export ZIG_GLOBAL_CACHE_DIR=fat32.mnt
On Windows, this should already be the case with the default NTFS filesystem. Then, run the following command:
$ zig fetch https://github.com/ianprime0509/pathological-packages/archive/e945a092051ea267a5af2655525cbed0d7d5b901.zip
error: zip extract failed: BadPathName
Expected Behavior
The package should be fetched successfully, as the problematic file is not listed in paths in build.zig.zon. Fetching using a tar.gz URL or Git URL produces this expected behavior:
$ zig fetch https://github.com/ianprime0509/pathological-packages/archive/e945a092051ea267a5af2655525cbed0d7d5b901.tar.gz
illegal_file_name-0.0.0-Jk3MdE0AAAA6Vv0NmnZkYPYNarGw6NVXpWHFitmwuR6Y
$ zig fetch git+https://github.com/ianprime0509/pathological-packages#e945a092051ea267a5af2655525cbed0d7d5b901
illegal_file_name-0.0.0-Jk3MdE0AAAA6Vv0NmnZkYPYNarGw6NVXpWHFitmwuR6Y
This is because std.tar continues after the error when diagnostics is set:
https://github.com/ziglang/zig/blob/518105471e145c90809fb2f5baa53cd08bde31aa/lib/std/tar.zig#L657-L666
while std.zip just uses try directly:
https://github.com/ziglang/zig/blob/518105471e145c90809fb2f5baa53cd08bde31aa/lib/std/zip.zig#L539-L548
So one possible fix would be to add a unable_to_create_file diagnostic to std.zip a la std.tar.