Closed n1yn closed 1 year ago
It looks right. How did you install zig? You can try clearing your global zig cache, usually in ~/.cache/zig
. Maybe, for some reason, downloading the deps got messed up?
Weird. You got the hash wrong in build.zig.zon
. The correct one is: 122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3
Feel free to reopen if the correct hash doesn't solve your problem
Well I don't even get to the point of building if I use the provided hash:
Fetch Packages [1/1] zap... /home/jotunn/Projects/zig/zig-web-server/build.zig.zon:7:21: error: hash mismatch: expected: 122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3, found: 12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
That's the reason I set the hash to 12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91
.
Then I get the following:
Fetch Packages [2/2] zap.facil.io... /home/jotunn/.cache/zig/p/12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91/build.zig.zon:8:21: error: hash mismatch: expected: 12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3, found: 12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a
.hash = "12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3",
Then I change the hash to 12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a
to get at least something. And that's the point it complains for not finding the zap module.
Then please wget or curl -v the url you have in build.zig.zon and verify it downloads the .tar.gz. I used the .deps from the readme just now to confirm both url and hash are correct. I can only imagine you're behind some weird proxy or something that messes with fetching the package. Hang on, I'll try the deps you provided, maybe there's something I overlooked.
When I use your build.zig.zon's dependencies, I get:
.dependencies = .{
.zap = .{
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
.hash = "12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a",
}
}
zig build
Fetch Packages [1/1] zap... /home/rs/code/github.com/nim-artificial-intelligence/digital-nudges-shop/build.zig.zon:8:21: error: hash mismatch: expected: 12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a, found: 122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3
.hash = "12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I use:
.dependencies = .{
// zap v0.1.14-pre
.zap = .{
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
}
}
it works again.
This is an issue not of zap. It's more one with the zig package manager, but I really think it's your setup. Would be interested to see what you get when you do a wget -v https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz
I get:
wget -v https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz
--2023-09-25 21:26:37-- https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/zigzap/zap/tar.gz/refs/tags/v0.1.14-pre [following]
--2023-09-25 21:26:37-- https://codeload.github.com/zigzap/zap/tar.gz/refs/tags/v0.1.14-pre
Resolving codeload.github.com (codeload.github.com)... 140.82.121.9
Connecting to codeload.github.com (codeload.github.com)|140.82.121.9|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v0.1.14-pre.tar.gz.1’
v0.1.14-pre.tar.gz.1 [ <=> ] 1.74M 10.8MB/s in 0.2s
2023-09-25 21:26:37 (10.8 MB/s) - ‘v0.1.14-pre.tar.gz.1’ saved [1826678]
Well I don't even get to the point of building if I use the provided hash:
Fetch Packages [1/1] zap... /home/jotunn/Projects/zig/zig-web-server/build.zig.zon:7:21: error: hash mismatch: expected: 122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3, found: 12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91 .hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
That's the reason I set the hash to
12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91
. Then I get the following:Fetch Packages [2/2] zap.facil.io... /home/jotunn/.cache/zig/p/12202d26b8c618b661ac5c9f96c11926f931fbea6afd302b7e71df9b3d256e79db91/build.zig.zon:8:21: error: hash mismatch: expected: 12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3, found: 12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a .hash = "12200301960bbde64052db068cf31a64091ce1f671898513d9b8d9e2be5b0e4b13a3",
Then I change the hash to
12206956e1c8e1af5fd28e44d534e4e131299545fa0676e1edc04bf02eb2185e266a
to get at least something. And that's the point it complains for not finding the zap module.
Above we see that whatever messes with the download, changes the hash of the zap dependency. When you fix the hash, it downloads zap correctly but then fails to fetch the dependency contained within zap's build.zig.zon that it just unpacked.
In that case, a workaround is: try building zap itself. That will try to fetch zap's dependency and fail. You can fix zap's build.zig.zon with the hash from the error message and try again. It shouldn't complain anymore. Then, facil.io should be in you zig package cache and maybe the package manager won't try to fetch it again when you try to build your project.
I asked how you installed zig. Now I ask about your setup: are you using some proxy / vpn / ... that could play man-in-the-middle?
I'm relatively new to zig so it is likely that I'm doing things wrong.
Steps to reproduce
Follow the basic instructions to add zap to your project:
build.zig.zon:
build.zig
What happens?
As soon as I run
zig build run
I get the following output:It complains about being unable to find the zap module.
Any help is welcome.