authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2025-07-25 17:38:36+02:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-07-30 22:40:36+01:00
logde23ccfad1630e30d5b5ea1278ab2f375f987568
treeeb91febc2b2b1f5d153a8657cf83fdf8a2206aec
parenteb1a4970dae76b49fe8cf1fa792a571cfebed86d

build system: print captured stderr on Run step failure

when a Run step that captures stderr fails, no output from it is visible by the user and, since the step failed, any downstream step that would process the captured stream will not run, making it impossible for the user to see the stderr output from the failed process invocation, which makes for a frustrating puzzle when this happens in CI.

1 files changed, 10 insertions(+), 0 deletions(-)

lib/std/Build/Step/Run.zig+10
......@@ -1391,6 +1391,16 @@ fn runCommand(
13911391 }
13921392 },
13931393 else => {
1394 // On failure, print stderr if captured.
1395 const bad_exit = switch (result.term) {
1396 .Exited => |code| code != 0,
1397 .Signal, .Stopped, .Unknown => true,
1398 };
1399
1400 if (bad_exit) if (result.stdio.stderr) |err| {
1401 try step.addError("stderr:\n{s}", .{err});
1402 };
1403
13941404 try step.handleChildProcessTerm(result.term, cwd, final_argv);
13951405 },
13961406 }