authorgravatar for hixuyuming@gmail.comhixuyuming <hixuyuming@gmail.com> 2026-01-02 02:51:16+01:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-01-02 02:51:16+01:00
log0c5f879b981352a84edb6daa09a1d6cdb53378d7
tree757f0572d732746f867008751a167579f05618a3
parent2bd02883c7260bb60e3c896bba37a7e6f403769f

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>

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/Build.zig+2-2
......@@ -1765,7 +1765,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
17651765 const io = b.graph.io;
17661766 const arena = b.allocator;
17671767
1768 if (Io.Dir.realPathFileAbsoluteAlloc(io, full_path, arena)) |p| {
1768 if (b.build_root.handle.realPathFileAlloc(io, full_path, arena)) |p| {
17691769 return p;
17701770 } else |err| switch (err) {
17711771 error.OutOfMemory => @panic("OOM"),
......@@ -1779,7 +1779,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
17791779 while (it.next()) |ext| {
17801780 if (!supportedWindowsProgramExtension(ext)) continue;
17811781
1782 return Io.Dir.realPathFileAbsoluteAlloc(
1782 return b.build_root.handle.realPathFileAlloc(
17831783 io,
17841784 b.fmt("{s}{s}", .{ full_path, ext }),
17851785 arena,