Some build steps add a bunch of newlines in Zig 0.13.0

I have a project (soon to be released!), and some build steps have started adding a bunch of newlines between prompts. zig build does it, zig build cov does it, but zig build test doesn’t.

Is anyone else seeing this? It looks like the progress bar inserts newlines for the build steps, if I hit Return in the middle one of the progress lines starts drifting up, implying that the progress indicator is creating the newlines. I specify this because there are a bunch of newlines also added before the progress bar starts up.

But only for some build steps! zig build test is immune.

1 Like

That didn’t take long :sweat_smile:

I had added coverage to the default build step (incorrectly, I was cargo-culting someone else’s build file, as one does) and when I remove that, it’s pretty clearly the interaction with kcov, not Zig, which is adding all the newlines.

Annoying, but not a Zig thing. I’m leaving this post up because using kcov with Zig is pretty common (or should be), and someone else might run into this phenomenon and wonder what’s going on.

I’m having this problem too in Windows, using both cmd.exe and the visual studio code terminal. I don’t even know what kcov is. It happens randomly in my case.

1 Like

Maybe try calling kcov_run_step.captureStdErr() and/or kcov_run_step.captureStdOut() to see if kcov outputting to one/both of them is the cause.

1 Like

Great suggestion! _ = cov_run.captureStdErr(); keeps the extra lines from happening. Interestingly, _ = cov_run.captureStdOut(); dumped a bunch of text intermixed with the process, but only once. There’s some sort of race condition going on there which makes me a bit uncomfortable, although resource contention for a tty pipe during a build is not the worst thing which can happen. I’m going to leave them both captured for now.

1 Like

I noticed this with nix build logs as well, one workaround is to set TERM=dumb

1 Like