Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libmain: fix ignoring empty lines in the print-build-logs option #12133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

momeemt
Copy link
Member

@momeemt momeemt commented Jan 3, 2025

Closes: #11991

Motivation

The logger previously ignored empty lines in the print-build-logs option.

Running the following nix file with this option shows that empty lines are not printed in the log, even though the build script prints them.

# repro.nix

let buildscript = builtins.toFile "build.sh" ''
	#!/bin/sh
	echo "start"
	echo
	echo
	echo
	echo "end"
	: > $out
'';
in
builtins.derivation {
	name = "repro";
	builder = "/bin/sh";
	args = [ buildscript ];
	outputs = [ "out" ];
	system = builtins.currentSystem;
}
$ nix build -f ./repro.nix -L --rebuild
repro> start
repro> end
$ nix log -f ./repro.nix | cat
start



end

I fixed the problem by removing !lastLine.empty(), so it now outputs like this.

$ nix build -f ./repro.nix -L --rebuild
repro> start
repro>
repro>
repro>
repro> end
$nix log -f ./repro.nix | cat
start



end

Context

This problem was reported by #11991.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@momeemt momeemt requested a review from edolstra as a code owner January 3, 2025 04:27
@Mic92
Copy link
Member

Mic92 commented Jan 6, 2025

https://discourse.nixos.org/t/2024-12-04-nix-team-meeting-minutes-200/57005

In our nix meeting we decided that it should not print repeated empty lines. A single empty line is fine.

@momeemt
Copy link
Member Author

momeemt commented Jan 8, 2025

discourse.nixos.org/t/2024-12-04-nix-team-meeting-minutes-200/57005

In our nix meeting we decided that it should not print repeated empty lines. A single empty line is fine.

Please let me check just to be sure.
The current implementation does not output a blank line, is it correct to fix compressing to a single empty line?
Or is it to close this pull request?

@Mic92
Copy link
Member

Mic92 commented Jan 8, 2025

@momeemt So just now it emits no empty newline and we would be ok with emitting one empty newline and than discarding the rest. Unless we have a real good use case for multiple new lines, we think just having one empty newline makes logs more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--print-build-logs|-L ignores empty lines
2 participants