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

Improve nix error reporting in bazel logs #389

Merged
merged 1 commit into from
May 24, 2023
Merged

Conversation

layus
Copy link
Collaborator

@layus layus commented May 24, 2023

This changes the old ans somewhat monolithic error output format to an indented and hopefully easier to read output.
Indentation is introduced make the log easier to parse which is direly needed when color is disabled, as in CI.

New:

ERROR: An error occurred during the fetch of repository 'foo':
   Traceback (most recent call last):
        File ".../external/rules_nixpkgs_core/nixpkgs.bzl", line 312, column 34, in _nixpkgs_package_impl
                exec_result = execute_or_fail(
        File ".../external/rules_nixpkgs_core/util.bzl", line 76, column 13, in execute_or_fail
                fail("""
Error in fail:
  Cannot build Nix attribute ''.
    Command: ".../nix-build" "-I" "nixpkgs=.../host_nixpkgs/host_nixpkgs" "-E" "some expr" "-A" "" "--out-link" "bazel-support/nix-out-link"
    Return code: 1
    Error output:
      > this derivation will be built:
      >   /nix/store/<hash>-foo-1.0.drv
      > building '/nix/store/<hash>-foo-1.0.drv'...
      > unpacking sources
      > unpacking source archive /nix/store/<hash>-source
      > source root is source
      > patching sources
      > configuring
      > no configure script, doing nothing
      > building
      > error: builder for '/nix/store/<hash>-foo-1.0.drv' failed with exit code 1;
      >        last 8 log lines:
      >        > unpacking sources
      >        > unpacking source archive /nix/store/<hash>-source
      >        > source root is source
      >        > patching sources
      >        > configuring
      >        > no configure script, doing nothing
      >        > building
      >        For full logs, run 'nix log /nix/store/<hash>-foo-1.0.drv'.

Old:

ERROR: An error occurred during the fetch of repository 'foo':
   Traceback (most recent call last):
	File ".../external/rules_nixpkgs_core/nixpkgs.bzl", line 312, column 34, in _nixpkgs_package_impl
		exec_result = execute_or_fail(
	File ".../external/rules_nixpkgs_core/util.bzl", line 76, column 13, in execute_or_fail
		fail("""
Error in fail: 
Cannot build Nix attribute ''.
Command: [.../nix-build, "-I", "nixpkgs=.../host_nixpkgs/host_nixpkgs", "-E", "some expr", "-A", "", "--out-link", "bazel-support/nix-out-link"]
Return code: 1
Error output:
this derivation will be built:
  /nix/store/<hash>-foo-1.0.drv
building '/nix/store/<hash>-foo-1.0.drv'...
unpacking sources
unpacking source archive /nix/store/<hash>-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
error: builder for '/nix/store/<hash>-foo-1.0.drv' failed with exit code 1;
       last 8 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/<hash>-source
       > source root is source
       > patching sources
       > configuring
       > no configure script, doing nothing
       > building
       For full logs, run 'nix log /nix/store/<hash>-foo-1.0.drv'.

@layus layus requested a review from benradf as a code owner May 24, 2023 10:40
Copy link
Contributor

@benradf benradf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@layus layus added the merge-queue merge on green CI label May 24, 2023
@mergify mergify bot merged commit f8fcfb1 into master May 24, 2023
@mergify mergify bot deleted the improve-error-logs branch May 24, 2023 11:31
@mergify mergify bot removed the merge-queue merge on green CI label May 24, 2023
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.

2 participants