Skip to content

Commit e0898f4

Browse files
committed
Step.Run: Fix for convertPathArg when cwd and path args are on different drives
Fixes #25805
1 parent 416bf1d commit e0898f4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,12 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {
746746
// Convert it from relative to *our* cwd, to relative to the *child's* cwd.
747747
break :rel std.fs.path.relative(b.graph.arena, child_cwd, path_str) catch @panic("OOM");
748748
};
749-
assert(!std.fs.path.isAbsolute(child_cwd_rel));
749+
// Not every path can be made relative, e.g. if the path and the child cwd are on different
750+
// disk designators on Windows. In that case, `relative` will return an absolute path which we can
751+
// just return.
752+
if (std.fs.path.isAbsolute(child_cwd_rel)) {
753+
return child_cwd_rel;
754+
}
750755
// We're not done yet. In some cases this path must be prefixed with './':
751756
// * On POSIX, the executable name cannot be a single component like 'foo'
752757
// * Some executables might treat a leading '-' like a flag, which we must avoid

0 commit comments

Comments
 (0)