Repository navigation
fix(build): use ZIG_GLOBAL_CACHE_DIR for Zig 0.17+ - #172
Merged
Merged
Conversation
Zig 0.17.0 broke the build in two places: 1. `--global-cache-dir` was removed from the `zig build` subcommand (it is only accepted by build-exe/run now), so nightly builds failed with 'error: unrecognized argument: --global-cache-dir'. Use the ZIG_GLOBAL_CACHE_DIR env var instead, which every Zig release honors and which already had to be set for the fetch step. 2. Standalone `zig fetch` now caches tarballs with the upstream top-level directory still nested, so the subsequent `zig build` re-hashes them and fails with 'hash mismatch'. `zig build --fetch=all` fills the cache in the layout the build expects and also resolves lazy/transitive deps, which is exactly what fetch-zig-cache.sh worked around. Upstream tip bumped minimum_zig_version to 0.17.0 and the version is read dynamically from build.zig.zon, so both regressions appeared without any change in this repo. Zig < 0.16 keeps the previous behaviour.
psadi
force-pushed
the
fix/zig-0.17-offline-cache
branch
from
October 27, 2026 19:22
be91fe5 to
fb0eb4b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nightly builds have failed every day since 2026-10-21. Two separate Zig 0.17.0 regressions are responsible;
ZIG_VERSIONis read dynamically from upstreambuild.zig.zon(minimum_zig_version), so both appeared without any change in this repo once tip moved to 0.17.0.1.
--global-cache-dirwas removed fromzig buildZig 0.17.0 only accepts
--global-cache-dironbuild-exe/run, notzig build, so the build died seconds after starting:Fix: feed the pre-fetched offline cache through
ZIG_GLOBAL_CACHE_DIR, which every Zig release honors (and whichfetch-zig-cache.shalready required). No version-gated CLI flag is needed any more.2.
zig fetchcaches tarballs in a layoutzig buildrejectsWith the flag fixed, the build then failed with hash mismatches for all 37 dependencies:
In 0.17.0, standalone
zig fetchstores the package tarball with the upstream top-level directory still nested (<hash>/zlib-1.3.1/...), whilezig buildexpects package-root-relative paths and therefore re-hashes it as a different package. Reproduced outside containers with a clean global cache; a plainzig buildfetch produces the correct layout.Fix: on Zig >= 0.17 pre-populate the cache with
zig build --fetch=all(new in 0.17), which writes the layout the build expects and resolves lazy/transitive deps itself — the exact gapnix/build-support/fetch-zig-cache.shused to work around.Zig < 0.16 keeps the previous
--system /tmp/offline-cache/p+ fetch-script behaviour.Verification
zig build --fetch=allon the tip source succeeds, and the followingzig buildno longer reports hash mismatches.shellcheck --severity=warning --shell=sh,shfmt, and the rest of pre-commit pass.setup-env→build-ghostty→bundle-appimage→validate-appimage) running in the same Arch container CI uses; this PR run is the end-to-end check.Note: transient
500s fromdeps.files.ghostty.orgwere seen while testing; unrelated to this change.