zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit de23ccfad1630e30d5b5ea1278ab2f375f987568 (tree)
parent eb1a4970dae76b49fe8cf1fa792a571cfebed86d
Author: Loris Cro <kappaloris@gmail.com>
Date:   Fri, 25 Jul 2025 17:38:36 +0200

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.

Diffstat:
Mlib/std/Build/Step/Run.zig | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git 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); }, }