Fix: tryFindProgram fails when $PATH contains relative paths (#30619)

Fixes a issue in tryFindProgram where it would fail if the PATH environment variable contained relative paths, due to its incorrect assumption that the full_path argument is always absolute path.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30619
Co-authored-by: hixuyuming <hixuyuming@gmail.com>
Co-committed-by: hixuyuming <hixuyuming@gmail.com>
This commit is contained in:
hixuyuming 2026-01-02 02:51:16 +01:00 committed by Ryan Liptak
parent 2bd02883c7
commit 0c5f879b98

View file

@ -1765,7 +1765,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
const io = b.graph.io;
const arena = b.allocator;
if (Io.Dir.realPathFileAbsoluteAlloc(io, full_path, arena)) |p| {
if (b.build_root.handle.realPathFileAlloc(io, full_path, arena)) |p| {
return p;
} else |err| switch (err) {
error.OutOfMemory => @panic("OOM"),
@ -1779,7 +1779,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
while (it.next()) |ext| {
if (!supportedWindowsProgramExtension(ext)) continue;
return Io.Dir.realPathFileAbsoluteAlloc(
return b.build_root.handle.realPathFileAlloc(
io,
b.fmt("{s}{s}", .{ full_path, ext }),
arena,