From de23ccfad1630e30d5b5ea1278ab2f375f987568 Mon Sep 17 00:00:00 2001 From: Loris Cro Date: Fri, 25 Jul 2025 17:38:36 +0200 Subject: [PATCH] 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. --- lib/std/Build/Step/Run.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 57f5d73f0c3496cffa935eac08c6d774b70f1974..819fc6745d4e10f94f7aca0b5e1cd1350d5ff1b0 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1391,6 +1391,16 @@ fn runCommand( } }, else => { + // On failure, print stderr if captured. + const bad_exit = switch (result.term) { + .Exited => |code| code != 0, + .Signal, .Stopped, .Unknown => true, + }; + + if (bad_exit) if (result.stdio.stderr) |err| { + try step.addError("stderr:\n{s}", .{err}); + }; + try step.handleChildProcessTerm(result.term, cwd, final_argv); }, } -- 2.54.0