Zig "dependency not found" in build.zig.zon in CI
When build.zig calls b.dependency("name", ...), Zig looks that name up in the .dependencies table of build.zig.zon. If it is not declared there, the build fails before fetching anything.
What this error means
zig build fails with "error: dependency X not found" pointing at the b.dependency call, because build.zig.zon has no matching entry.
zig
build.zig:12:32: error: dependency 'mecha' not found
const mecha = b.dependency("mecha", .{});Common causes
The dependency is not in build.zig.zon
b.dependency("name") requires a key of the same name under .dependencies in the manifest; a missing or misnamed key fails the lookup.
The manifest was not added with zig fetch
The dependency was referenced in build.zig but never registered in build.zig.zon with zig fetch --save.
How to fix it
Add the dependency to the manifest
- Run
zig fetch --savewith the dependency URL to add it to build.zig.zon. - Confirm the key matches the name used in
b.dependency(...). - Commit build.zig.zon so CI has the declaration.
Terminal
zig fetch --save https://github.com/Hejsil/mecha/archive/refs/tags/0.9.0.tar.gzAlign the name in build.zig with the manifest key
The string passed to b.dependency must equal the key under .dependencies exactly.
build.zig.zon
.dependencies = .{
.mecha = .{ .url = "...", .hash = "..." },
},How to prevent it
- Register dependencies with
zig fetch --saveso the manifest stays in sync. - Keep the
b.dependencyname identical to the manifest key. - Commit build.zig.zon alongside build.zig changes.
Related guides
Zig "incompatible zig version" (0.13 vs 0.14) in CIFix the Zig build error about an incompatible compiler version in CI - build.zig.zon declares a minimum_zig_v…
Zig "unable to find zig installation directory" in CIFix Zig "unable to find zig installation directory" in CI - the zig binary cannot locate its bundled lib dire…
Zig "the following command failed" in zig build in CIFix Zig "error: the following command failed with exit code N" in CI - a build step (a run, test, or external…