Skip to content

Resolve the gate's zig from the build, not one contributor's home directory - #74

Merged
ywy50 merged 2 commits into
mainfrom
gate-zig-exe-from-build
Aug 12, 2026
Merged

Resolve the gate's zig from the build, not one contributor's home directory#74
ywy50 merged 2 commits into
mainfrom
gate-zig-exe-from-build

Conversation

@ywy50

@ywy50 ywy50 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

resolveZigBin listed /home/maci/.local/bin/zig and /home/maci/.zvm/0.16.0/zig
and nothing else, so on any other machine it returned null and runZig fell back
to a bare "zig". Every gate runs with cwd set to a staging or temp directory,
and that argv[0] is not found from there: on macOS the fmt and ast-check gates
failed at spawn, before zig ever saw the code they were meant to check.

Two of this file's own tests failed on a clean checkout for the same reason
("astCheckGate fails on a syntax error with a precise diagnostic" and "fmtGate
catches unformatted code and formatFiles fixes it"), which is how a red gate
became the normal state of the suite.

build.zig now passes b.graph.zig_exe through build_options. The interpreter that
built the binary is the right version by construction and is an absolute path,
which is the property that actually matters here. The two fixed paths stay
behind it for a binary whose build cache has since been cleared, and both are
skipped unless absolute.

zig build test: 135/135 steps, 416/418 passed, 2 skipped.

Summary by CodeRabbit

  • Chores

    • Improved build-time configuration to reliably locate the tooling needed for code quality checks.
    • Added fallback handling for environments where the primary tool location is unavailable.
    • Invalid, missing, or non-executable tool paths are now safely ignored.
  • Tests

    • Added coverage confirming that a valid tool installation can be detected correctly.

…ectory

resolveZigBin listed /home/maci/.local/bin/zig and /home/maci/.zvm/0.16.0/zig
and nothing else, so on any other machine it returned null and runZig fell back
to a bare "zig". Every gate runs with cwd set to a staging or temp directory,
and that argv[0] is not found from there: on macOS the fmt and ast-check gates
failed at spawn, before zig ever saw the code they were meant to check.

Two of this file's own tests failed on a clean checkout for the same reason
("astCheckGate fails on a syntax error with a precise diagnostic" and "fmtGate
catches unformatted code and formatFiles fixes it"), which is how a red gate
became the normal state of the suite.

build.zig now passes b.graph.zig_exe through build_options. The interpreter that
built the binary is the right version by construction and is an absolute path,
which is the property that actually matters here. The two fixed paths stay
behind it for a binary whose build cache has since been cleared, and both are
skipped unless absolute.

zig build test: 135/135 steps, 416/418 passed, 2 skipped.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ywy50, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 06381416-8afa-468f-a874-a3eecd8b4786

📥 Commits

Reviewing files that changed from the base of the PR and between 98915d9 and 927013c.

📒 Files selected for processing (1)
  • src/gate/checks.zig
📝 Walkthrough

Walkthrough

The build now passes the active Zig executable path to gate checks. Gate checks prefer this path, ignore empty or relative paths, retain absolute fallbacks, and verify that the selected path is executable.

Changes

Zig executable resolution

Layer / File(s) Summary
Expose the Zig executable path
build.zig
The build adds the zig_exe option from b.graph.zig_exe.
Resolve and test the executable
src/gate/checks.zig
Gate checks use the configured path before fixed absolute fallbacks. Empty and relative paths are skipped. A test verifies the resolved path.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • maci0/clanker#72: Both changes update Zig executable resolution for gate checks.
  • maci0/clanker#73: Both changes update Zig binary handling for spawn-dependent gate checks.

Suggested reviewers: maci0

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: resolving the gate's Zig executable from the build instead of a contributor-specific path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch gate-zig-exe-from-build
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gate-zig-exe-from-build

Comment @coderabbitai help to get the list of available commands.

main reached the same two red tests from the other side, with
skipIfNoSpawnableZig: turn "zig could not be spawned" into a skip rather than a
failure. Both are kept. That helper is the backstop for a machine with no usable
compiler; resolving zig_exe from the build is what stops the condition arising,
so on any machine that still has the build's compiler the gates now run instead
of skipping.

zig build / tools / test all green: 135/135 steps, 416/418 passed, 2 skipped.
@ywy50
ywy50 merged commit 012f2f0 into main Aug 12, 2026
1 of 2 checks passed
@ywy50
ywy50 deleted the gate-zig-exe-from-build branch August 12, 2026 04:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/gate/checks.zig (1)

699-710: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert that the build-provided candidate was selected.

The test passes when any fixed fallback is executable. It does not prove that build_options.zig_exe reached resolveZigBin. A regression can therefore pass on a machine with /home/maci/.local/bin/zig. Assert equality with build_options.zig_exe; add a separate fallback test if fallback behavior also needs coverage.

Suggested assertion
-    try std.testing.expect(bin[0] == '/');
+    try std.testing.expect(build_options.zig_exe.len > 0);
+    try std.testing.expectEqualStrings(build_options.zig_exe, bin);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/gate/checks.zig` around lines 699 - 710, Update the test “resolveZigBin
finds the zig that built this binary” to assert that the returned path equals
the build-provided build_options.zig_exe value, rather than only checking that
it is absolute. Preserve the existing allocation and cleanup flow; add separate
fallback coverage only if needed elsewhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/gate/checks.zig`:
- Around line 690-693: Update the path filter in the gate check around
build_options.zig_exe to use std.fs.path.isAbsolute(k) instead of checking k[0]
against '/'. Preserve the empty-path skip and subsequent
std.Io.Dir.accessAbsolute validation so POSIX, drive-letter, and UNC absolute
paths are accepted.

---

Nitpick comments:
In `@src/gate/checks.zig`:
- Around line 699-710: Update the test “resolveZigBin finds the zig that built
this binary” to assert that the returned path equals the build-provided
build_options.zig_exe value, rather than only checking that it is absolute.
Preserve the existing allocation and cleanup flow; add separate fallback
coverage only if needed elsewhere.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f34b4597-5de4-437b-8e29-62ad520ce6a3

📥 Commits

Reviewing files that changed from the base of the PR and between bc4054a and 98915d9.

📒 Files selected for processing (2)
  • build.zig
  • src/gate/checks.zig

Comment thread src/gate/checks.zig
Comment on lines +690 to 693
// Relative, or empty on a build that predates the option: `cwd` is not
// this process's, so it could not be resolved against anything useful.
if (k.len == 0 or k[0] != '/') continue;
std.Io.Dir.accessAbsolute(io, k, .{ .execute = true }) catch continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- relevant source ---'
sed -n '1,40p' src/gate/checks.zig
sed -n '650,725p' src/gate/checks.zig
printf '%s\n' '--- target selection ---'
sed -n '1,70p' build.zig
printf '%s\n' '--- path handling and option definitions ---'
rg -n -C 3 'zig_exe|resolveZigBin|accessAbsolute|isAbsolute|absolute' src build.zig
printf '%s\n' '--- tracked Zig/toolchain metadata ---'
git ls-files | rg '(^|/)(build\.zig|build\.zig\.zon|.*\.zig)$' | head -80
command -v zig || true
zig version 2>/dev/null || true

Repository: maci0/clanker

Length of output: 38190


🌐 Web query:

Zig 0.16.0 std.fs.path.isAbsolute Windows drive UNC path source

💡 Result:

In Zig 0.16.0, std.fs.path.isAbsolute correctly identifies Windows UNC paths as absolute [1][2]. The standard library's path handling logic was significantly improved in recent versions to treat UNC paths (e.g., \server\share) as a distinct and fully supported absolute path type [3][4][5]. Internally, std.fs.path.isAbsolute on Windows delegates to isAbsoluteWindows, which relies on windows.getWin32PathType to categorize the path [2]. This categorization specifically classifies.unc_absolute as one of the types that returns true for being absolute [2]. Key technical details: - Mechanism: The isAbsoluteWindowsImpl function evaluates paths based on their Win32 path type [2]. The.unc_absolute variant is explicitly included in the set of absolute path types (.drive_absolute,.unc_absolute,.local_device,.root_local_device) [2]. - Evolution: Earlier versions of Zig had limited support for complex Windows path formats, which occasionally caused issues or panics when encountering UNC paths [6]. These have been resolved in modern versions (including 0.16.0) by implementing a more robust parser that correctly handles the various Windows path formats, including UNC [3][4][7]. - API usage: You can use std.fs.path.isAbsolute(path) to reliably check if a path is absolute on Windows, and it will return true for valid UNC paths [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
import urllib.request

url = "https://raw.githubusercontent.com/ziglang/zig/0.16.0/lib/std/fs/path.zig"
text = urllib.request.urlopen(url, timeout=20).read().decode()
needles = (
    "pub fn isAbsolute(",
    "fn isAbsoluteWindows",
    ".drive_absolute",
    ".unc_absolute",
)
missing = [needle for needle in needles if needle not in text]
print("zig 0.16.0 path.zig fetched:", len(text), "bytes")
print("required symbols present:", not missing, missing)
for needle in needles:
    pos = text.find(needle)
    if pos >= 0:
        start = text.rfind("\n", 0, max(0, pos - 500))
        end = text.find("\n", pos + 900)
        print(f"\n--- {needle} ---")
        print(text[start:end if end >= 0 else pos + 1200])
PY
printf '%s\n' '--- runZig call path ---'
sed -n '735,790p' src/gate/checks.zig
printf '%s\n' '--- exact build target block ---'
sed -n '25,48p' build.zig

Repository: maci0/clanker

Length of output: 2437


Use a platform-aware absolute-path check.

When the native target is Windows, build_options.zig_exe can be a drive-letter or UNC path. The k[0] != '/' check skips it and prevents the gates from using the configured Zig executable. Replace it with std.fs.path.isAbsolute(k) for Zig 0.16.0.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/gate/checks.zig` around lines 690 - 693, Update the path filter in the
gate check around build_options.zig_exe to use std.fs.path.isAbsolute(k) instead
of checking k[0] against '/'. Preserve the empty-path skip and subsequent
std.Io.Dir.accessAbsolute validation so POSIX, drive-letter, and UNC absolute
paths are accepted.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant