Allow builds without a Git checkout #49

Open
opened 2026-05-22 13:05:47 +00:00 by rc · 0 comments
Owner

Finding:
zig build unconditionally shells out to git rev-parse HEAD to produce the CLI version.

Problem:

  • build.zig runs b.run(&.{ "git", "rev-parse", "HEAD" }) during build graph construction.
  • Source archives, vendored copies, or minimal build environments without git fail before compiling.

Impact:
Packaging and reproducible builds are more brittle than necessary; the code cannot be built from a plain source snapshot without extra VCS context.

Suggested fix:
Add an explicit -Dversion= build option, use the git hash only as a best-effort default when .git and git are available, and fall back to unknown or a release-provided version string.

Relevant code:

  • build.zig: version option generation around line 60.
Finding: `zig build` unconditionally shells out to `git rev-parse HEAD` to produce the CLI version. Problem: - `build.zig` runs `b.run(&.{ "git", "rev-parse", "HEAD" })` during build graph construction. - Source archives, vendored copies, or minimal build environments without `git` fail before compiling. Impact: Packaging and reproducible builds are more brittle than necessary; the code cannot be built from a plain source snapshot without extra VCS context. Suggested fix: Add an explicit `-Dversion=` build option, use the git hash only as a best-effort default when `.git` and `git` are available, and fall back to `unknown` or a release-provided version string. Relevant code: - `build.zig`: version option generation around line 60.
Sign in to join this conversation.
No labels
highprio
lowprio
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rc/vmz#49
No description provided.