From 0c5f879b981352a84edb6daa09a1d6cdb53378d7 Mon Sep 17 00:00:00 2001 From: hixuyuming Date: Fri, 2 Jan 2026 02:51:16 +0100 Subject: [PATCH] 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 Co-committed-by: hixuyuming --- lib/std/Build.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 317e4600a47d14d9f0fee390495635a93a127206..dc3489bba3104a312568a95eb15bac7d3eec3dd3 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -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, -- 2.54.0