Skip to content

Commit 219c8ef

Browse files
fix(ci): resolve zig via PATH when mise is unavailable (#48)
CI installs Zig directly via mlugg/setup-zig onto PATH (no mise on the Blacksmith runner), but _check-zig-version only ever tried mise which, so the zig job failed immediately with "mise is not on PATH" in its first real CI run.
1 parent 07abd9d commit 219c8ef

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

‎taskfiles/zig.yml‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ vars:
99
ZIG_CACHE_DIR: "{{.ZIG_CORE_DIR}}/.zig-cache"
1010
PINNED_ZIG:
1111
sh: grep '^zig ' {{.ROOT_DIR}}/.tool-versions 2>/dev/null | awk '{print $2}' || true
12-
# Resolved through mise against the pinned version rather than PATH, which may
13-
# hold an IDE-bundled zig or a mise default for a different version.
12+
# Prefers mise resolved against the pinned version (avoids an IDE-bundled zig
13+
# or a mise default for a different version), falling back to PATH for
14+
# environments where zig is installed directly, e.g. CI via mlugg/setup-zig.
1415
ZIG:
15-
sh: |
16+
sh: |
1617
pin="{{.PINNED_ZIG}}"
1718
if [ -n "$pin" ] && command -v mise &> /dev/null; then
18-
mise which zig --tool "zig@$pin" 2>/dev/null || true
19+
resolved=$(mise which zig --tool "zig@$pin" 2>/dev/null || true)
20+
if [ -n "$resolved" ]; then
21+
echo "$resolved"
22+
exit 0
23+
fi
1924
fi
25+
command -v zig 2>/dev/null || true
2026
# Explicit target triple for the cross-compile task, e.g. TARGET=aarch64-macos
2127
TARGET: '{{.TARGET | default ""}}'
2228

@@ -26,27 +32,22 @@ tasks:
2632
desc: "Verify the pinned zig resolves and matches .tool-versions"
2733
cmds:
2834
- |
29-
mise_bin="{{.ZIG}}"
30-
if [ ! -x "$mise_bin" ]; then
31-
if ! command -v mise &> /dev/null; then
32-
echo "error: zig {{.PINNED_ZIG}} not found and mise is not on PATH." >&2
33-
echo " Expected: {{.PINNED_ZIG}} (pinned in .tool-versions)" >&2
34-
echo " Fix: install mise (https://mise.jdx.dev), then run: mise install zig" >&2
35-
exit 1
36-
fi
37-
echo "error: zig {{.PINNED_ZIG}} (pinned in .tool-versions) is not installed." >&2
38-
echo " Fix: mise install zig" >&2
35+
zig_bin="{{.ZIG}}"
36+
if [ -z "$zig_bin" ] || [ ! -x "$zig_bin" ]; then
37+
echo "error: zig {{.PINNED_ZIG}} not found on mise or PATH." >&2
38+
echo " Expected: {{.PINNED_ZIG}} (pinned in .tool-versions)" >&2
39+
echo " Fix: install mise (https://mise.jdx.dev), then run: mise install zig" >&2
3940
exit 1
4041
fi
41-
found=$("$mise_bin" version 2>/dev/null)
42+
found=$("$zig_bin" version 2>/dev/null)
4243
if [ "$found" != "{{.PINNED_ZIG}}" ]; then
4344
echo "error: zig version mismatch." >&2
4445
echo " Expected: {{.PINNED_ZIG}} (pinned in .tool-versions)" >&2
45-
echo " Found: ${found:-unknown} ($mise_bin)" >&2
46+
echo " Found: ${found:-unknown} ($zig_bin)" >&2
4647
echo " Fix: mise install zig@{{.PINNED_ZIG}}" >&2
4748
exit 1
4849
fi
49-
echo "zig $found -> $mise_bin"
50+
echo "zig $found -> $zig_bin"
5051
5152
format:
5253
desc: "Format Zig source files"

0 commit comments

Comments
 (0)