zap icon indicating copy to clipboard operation
zap copied to clipboard

Using zap with BTRFS on Linux 6.5.0 causes a package hash mismatch

Open MarcusWagberg opened this issue 2 years ago • 6 comments

Versions: zig 0.11.0 zap 0.1.14-pre

Steps to reproduce:

  1. Create a new zig project with zig init-exe
  2. Create a build.zig.zon file from the example in the README:
.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.1.14-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
            .hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
        }
    }
}
  1. Clear zig cahce e.g run rm -rf ~/.cache/zig/ on linux
  2. Run zig build run

Output:

Fetch Packages [1/1] zap... /home/marcus/Downloads/b/build.zig.zon:9:21: error: hash mismatch: expected: 122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3, found: 12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91
            .hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


MarcusWagberg avatar Sep 27 '23 11:09 MarcusWagberg

If i use the hash 12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91 instead i get another hash mismatch:

Fetch Packages [2/2] zap.facil.io... /home/marcus/.cache/zig/p/12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91/build.zig.zon:8:21: error: hash mismatch: expected: 12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3, found: 12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a
            .hash = "12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3",
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


MarcusWagberg avatar Sep 27 '23 15:09 MarcusWagberg

I hope I'm not taking this issue on a tangent, but do you happen to be using Linux >6.4.12 with a BTRFS filesystem. I had nearly identical symptoms with a different package. Downgrading my kernel fixed the issue for me. For reference: ziglang/zig#17095

gcoakes avatar Oct 05 '23 01:10 gcoakes

I am using BTRFS on Linux 6.5.0 so this almost guaranteed to be the issue, i was unaware of the broader issue with BTRFS on certain 6.4.x and 6.5.x releases of linux.

MarcusWagberg avatar Oct 09 '23 11:10 MarcusWagberg

There are two workarounds for this issue:

  1. Use a kernel that is not in the > 6.4.12 && < 6.5.6 range (my fix)
  2. If using zig master set ZIG_BTRFS_WORKAROUND=1

See for more info: IterableDir does not iterate over all contents created after opening (Linux BTRFS) package manager: Transitive dependencies have incorrect hash

MarcusWagberg avatar Nov 15 '23 20:11 MarcusWagberg

@renerocksai should this issue be closed since it has now been resolved for me or should it remain open for others refrance?

MarcusWagberg avatar Nov 15 '23 20:11 MarcusWagberg

@MarcusWagberg I'll better keep it open until zig 0.12.0 arrives.

renerocksai avatar Jan 09 '24 10:01 renerocksai