From 5c4ab6c0de60def3ff6b0ca49f367fdf36abd50a Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 23 Apr 2026 09:59:41 +0900 Subject: [PATCH] build: pass zig exe path to combine_archives `combine_archives` spawns `zig ar -M` to combine static archives via an MRI script. It hard-coded the command name `"zig"` and relied on the binary being on `PATH`, which fails on Windows when the build is driven by an absolute zig.exe path (common in CI and in Scoop/winget installs where PATH isn't populated at build time). The failure surfaces as `error: FileNotFound` from `Child.spawn`. Pass `b.graph.zig_exe` as the first argument so the tool always uses the exact zig binary that is driving the build, matching how other build tools in this repo spawn zig subcommands. --- src/build/GhosttyLibVt.zig | 1 + src/build/combine_archives.zig | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/build/GhosttyLibVt.zig b/src/build/GhosttyLibVt.zig index ffd4962d9..c59f40de7 100644 --- a/src/build/GhosttyLibVt.zig +++ b/src/build/GhosttyLibVt.zig @@ -339,6 +339,7 @@ fn combineArchives( }), }); const run = b.addRunArtifact(tool); + run.addArg(b.graph.zig_exe); const output = run.addOutputFileArg("libghostty-vt.a"); for (sources) |source| run.addFileArg(source); diff --git a/src/build/combine_archives.zig b/src/build/combine_archives.zig index 04f2c0e49..04ec8e978 100644 --- a/src/build/combine_archives.zig +++ b/src/build/combine_archives.zig @@ -7,7 +7,7 @@ //! available on Windows. This tool handles both the script generation //! and the piping in a single cross-platform executable. //! -//! Usage: combine_archives [input2.a ...] +//! Usage: combine_archives [input2.a ...] const std = @import("std"); @@ -16,13 +16,14 @@ pub fn main() !void { const alloc = gpa.allocator(); const args = try std.process.argsAlloc(alloc); - if (args.len < 3) { - std.log.err("usage: combine_archives ", .{}); + if (args.len < 4) { + std.log.err("usage: combine_archives ", .{}); std.process.exit(1); } - const output_path = args[1]; - const inputs = args[2..]; + const zig_exe = args[1]; + const output_path = args[2]; + const inputs = args[3..]; // Build the MRI script. var script: std.ArrayListUnmanaged(u8) = .empty; @@ -36,7 +37,7 @@ pub fn main() !void { } try script.appendSlice(alloc, "SAVE\nEND\n"); - var child: std.process.Child = .init(&.{ "zig", "ar", "-M" }, alloc); + var child: std.process.Child = .init(&.{ zig_exe, "ar", "-M" }, alloc); child.stdin_behavior = .Pipe; child.stdout_behavior = .Inherit; child.stderr_behavior = .Inherit;