Removing or truncating lengthy debug info

Hello! I’ve been working on a raylib-zig project, which has been great. What hasn’t been so great is me however, is how long the error messages are. The /nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7... line in particular is problematic, filling most of my display on a build! Is there a way to remove/truncate this? I haven’t yet needed its contents. I assume the build system has a solution, but I haven’t found it. Something like --summary none would also be great, if I missed such a thing. This is surely partly because I’m on NixOS, maybe because of the flake I’m using. If seeing that would be of use, let me know.

Here’s an example error:

Vendetta/kriegsschiffe on  main [✘!?⇡] via ↯ v0.14.1 via ❄️  impure (nix-shell-env)
➜ zig build run -freference-trace=0 --summary none
run
└─ run vendetta
   └─ zig build-exe vendetta Debug native 1 errors
src/game.zig:28:30: error: expected type 'components.kriegsschiff.Kriegsschiffe', found 'array_list.ArrayListAligned(components.kriegsschiff.Kriegsschiff,null)'
            .kriegsschiffe = kriegsschiffe,
                             ^~~~~~~~~~~~~
/nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7-zig-0.14.1/lib/std/array_list.zig:31:12: note: struct declared here
    return struct {
           ^~~~~~
src/components/kriegsschiff.zig:82:27: note: struct declared here
pub const Kriegsschiffe = struct {
                          ^~~~~~
error: the following command failed with 1 compilation errors:
/nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7-zig-0.14.1/bin/zig build-exe -freference-trace=0 /home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/.zig-cache/o/2bdd25a0ecbce9efc77788fe0f1c2606/libraylib.a -ODebug -I /home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/.zig-cache/o/50a18a6d1e5244841d805ea56e9ca084 --dep raylib -Mroot=/home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/src/main.zig -ODebug -Mraylib=/home/yontuh/.cache/zig/p/raylib_zig-5.6.0-dev-KE8REKAqBQAQugfCOjYYVRFOi7iaEJK1EMDcRUq8AOm2/lib/raylib.zig -I/nix/store/y0c6p6cxq0nyh09lw0lpwps5i3dn1v6n-libglvnd-1.7.0-dev/include -L/nix/store/z88avybj8n2svi9wv1hl937k2k3mbc2d-libglvnd-1.7.0/lib -lGLX -I/nix/store/zllk6n33p6mx8y9cf4vhs2brcbis3na4-libX11-1.8.12-dev/include -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -L/nix/store/mpvxc1dbpnk74345lk69dw497iqcjvj0-libX11-1.8.12/lib -lX11 -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/crflxz9k6ns9867pdvgqfx7sk8480iv3-libXcursor-1.2.3-dev/include -L/nix/store/pkxrqwd26nqr7gh9d4gi9wf7hj6rk29a-libXcursor-1.2.3/lib -lXcursor -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/ky5yyp5zxkaxg4pk55xwm0ga53av3n4j-libXext-1.3.6-dev/include -L/nix/store/gmirqf6vp6rskn2dhfyd7haphy6kjnvk-libXext-1.3.6/lib -lXext -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/0dgx7r74f17d9flbbr6wcrpvprc403gg-libXfixes-6.0.1-dev/include -L/nix/store/21aj13sj7jg5ld96s3q7nd40s1iwzfld-libXfixes-6.0.1/lib -lXfixes -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/xshf6q24a68pyl7drky8nnfhkbcrg8zf-libXi-1.8.2-dev/include -L/nix/store/4sfqx63v2k8argz2wmnbspr0rh49y1c1-libXi-1.8.2/lib -lXi -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/mb8khia6fmk0qf3ddcw2hdrdqyqg1qqw-libXinerama-1.1.5-dev/include -L/nix/store/argsq168sn1bzp81indp4hijx0zmlm7n-libXinerama-1.1.5/lib -lXinerama -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/k75dyzqhlwm93xq37szypw5jq0y1s9p8-libXrandr-1.5.4-dev/include -L/nix/store/0jiignrsjnmzagq2mjd0mjqmjrm2r0rg-libXrandr-1.5.4/lib -lXrandr -I/nix/store/zllk6n33p6mx8y9cf4vhs2brcbis3na4-libX11-1.8.12-dev/include -I/nix/store/18w6fpxmn5px02bpfgk702bs9k7yj5ml-xorgproto-2024.1/include -I/nix/store/w0al2wra2s2yavli2pfqhmdcn7yb4hfh-libXrender-0.9.12-dev/include -L/nix/store/mpvxc1dbpnk74345lk69dw497iqcjvj0-libX11-1.8.12/lib -L/nix/store/pbg3xkihyscyx3978z0pfc0xixb10pf6-libXrender-0.9.12/lib -lXrender -lX11 -I/nix/store/y0c6p6cxq0nyh09lw0lpwps5i3dn1v6n-libglvnd-1.7.0-dev/include -L/nix/store/z88avybj8n2svi9wv1hl937k2k3mbc2d-libglvnd-1.7.0/lib -lEGL -I/nix/store/17mijr1mvgcz2mh22rs7h8qmipwf3m7w-wayland-1.23.1-dev/include -L/nix/store/mxyi7nahmxs41d2xnyfx9kvanqh3p706-wayland-1.23.1/lib -lwayland-client -I/nix/store/7jyyf32al4fm91a2dw6n3d8ykq2jxvxb-libxkbcommon-1.8.1-dev/include -L/nix/store/4di7f8w515xl6grwv13pk6855awav0b1-libxkbcommon-1.8.1/lib -lxkbcommon -lc --cache-dir /home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/.zig-cache --global-cache-dir /home/yontuh/.cache/zig --name vendetta --zig-lib-dir /nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7-zig-0.14.1/lib/ --listen=-
error: the following build command failed with exit code 1:
/home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/.zig-cache/o/56ad52bb9773e7792bf55622c2e33cec/build /nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7-zig-0.14.1/bin/zig /nix/store/rf2hmizxk6i2ryr08sh60yivmmpiw9l7-zig-0.14.1/lib /home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe /home/yontuh/code/zig/games/raylib/Vendetta/kriegsschiffe/.zig-cache /home/yontuh/.cache/zig --seed 0xf96d4d97 -Z5e51ed51879694b9 run -freference-trace=0 --summary none

Any suggestions to make the general error more concise (other than the specific, user errors) would be great. Thank you!

You can use --prominent-compile-errors which displays the compile errors at the end.

2 Likes

That’s a pretty good argument that I wasn’t aware of.

I too am not completely satisfied with how compiler errors get printed, I always find myself having to stop and look longer than I would like just to find the pertinent “what do I need to fix” line. This is compounded by my workflow of building in a terminal that is only in the bottom 1/3 of my screen, meaning I often also have to scroll upwards to see it.

Using this argument actually fixes both of those (minor) frustrations.

2 Likes

A much more involved approach (maybe a bit too much depending on how important it is to you and how much Zig experience you have) would be to copy the build runner and start changing how it works and prints things.
This build runner then could be used with --build-runner path

I also think there may be the possibility that someone comes up with some enhancement idea that could lead towards an issue to implement some kind of flag that improves the clarity of the output in the default build runner.

I think the main thing for such an issue to be accepted, would be that the idea is actually well thought out and fits, for that it would probably require to get familiar with the things that have been proposed and accepted/rejected already and then find whether there is still something in the design space that fits and demonstrate how it would be a compelling improvement.
But this is just me brainstorming and how I would approach it.

1 Like

This is a PR that attempts to improve the clarity of build output for zig build --watch. Instead of trying to find the most recent compile error(s) within a wall of text, it would be printed at a much more predictable location towards the top of the terminal. Whether the terminal gets cleared or some other clear delimiter between build outputs gets inserted remains to be seen, but hopefully this PR gets merged with some sort of improvement.

But as @Sze mentioned, you can make this modification (or any other, for that matter) to your own build runner, either within the Zig source tree or by copying the default build runner outside the tree and using the --build-runner flag.

1 Like