nix build should show more than the last 10 lines of output

Created on 14 Sep 2018  路  5Comments  路  Source: NixOS/nix

The Nix 2 nix build command truncates the log output for failed builds to 10 lines, which for most purposes (in my experience so far, at least) isn't enough to get any meaningful information. Should the build command have a flag to ask it nicely to print the entire output? I suppose what I'll do for now is write a wrapper script that calls log after build, but this seems like it ought to be wrapped up in the nix command itself, since I can't imagine ever not wanting to see the log after a build failure.

Most helpful comment

Or, slightly shorter:

$ nix log /nix/store/f81k0pc8c1jii699g538hdz74cvrc8z1-dist-files.drv

Or, much shorter (but doesn't work if it's a dependency that failed):

$ nix log .#dist-files

And just for completeness, to show the full log during build whether it ultimately fails or not:

$ nix build -L .#dist-files

All 5 comments

This has bitten me many times as well, I keep forgetting to open an issue about it. However, I don't think the flag should enable full logging, but rather it should disable it, with full error messages seeming as a more sensible (IMO) default. When encountering an error, I'd rather see the whole thing by default, than not (and have to call log or something). Either way a flag would be useful

IMO nix build should behave just like nix-build except maintaining the progress bar at the bottom... that would solve this problem too

It seems like we could expand the current behavior to just show the full log on failure, right? I like not seeing noisy logs if all is well, but since Nix is storing the build logs, it might as well show them if the build fails.

This issue was one of the top results while searching for how to display the full log.
For posterity: you can see the log by copying the store path mentioned in nix builds output to the nix store --read-log command.

$ nix build .#dist-files
warning: Git tree '/home/rkb/projects/tulars' is dirty
building '/nix/store/f81k0pc8c1jii699g538hdz74cvrc8z1-dist-files.drv'...
error: --- Error -------------------------------------------------------------------------------------------------------------------------------------------------- nix
builder for '/nix/store/f81k0pc8c1jii699g538hdz74cvrc8z1-dist-files.drv' failed with exit code 2; last 10 log lines:
  npm ERR!   path: '/homeless-shelter'
  <...some other mangled log lines...>
$ nix-store --read-log /nix/store/f81k0pc8c1jii699g538hdz74cvrc8z1-dist-files.drv

Or, slightly shorter:

$ nix log /nix/store/f81k0pc8c1jii699g538hdz74cvrc8z1-dist-files.drv

Or, much shorter (but doesn't work if it's a dependency that failed):

$ nix log .#dist-files

And just for completeness, to show the full log during build whether it ultimately fails or not:

$ nix build -L .#dist-files
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrnewton picture rrnewton  路  34Comments

LisannaAtHome picture LisannaAtHome  路  42Comments

edolstra picture edolstra  路  96Comments

matthewbauer picture matthewbauer  路  64Comments

Profpatsch picture Profpatsch  路  73Comments