Skip to content

Include the derivation's output path in the "dependency failed" error - #47

Closed
grahamc wants to merge 2 commits into
detsys-mainfrom
push-uoyzlsnlusvu
Closed

grahamc wants to merge 2 commits into
detsys-mainfrom
push-uoyzlsnlusvu

Conversation

@grahamc

@grahamc grahamc commented Apr 29, 2025 •

Copy link
Copy Markdown
Member

ref: https://linear.app/detsys/issue/FH-783/improve-the-build-failure-message

Motivation

Semi-regularly we have folks (internal and external) get frustrated by this error message:

error: 1 dependencies of derivation '/nix/store/storepath-xxxxx.drv' failed to build

...especially when that path is expected to be substitutable, and knowing the output path would let you check binary caches.

This patch does a couple things:

  1. Makes the error feel a touch more polished by properly pluralizing "dependency" / "dependencies",
  2. includes the first output path of the derivation if possible, and uses the derivation name if it is not possible.

Here's what the new error looks like:

error: hash mismatch in fixed-output derivation '/nix/store/9kj4ljvvzz0qzqgqk46a3zg02pjffmvh-x2.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-ce9j/VcjC18vmZgcaMAqZg/qH/WibuYfiyiOYHNI5pk=
error: 1 dependency of /nix/store/glh5ni12yk22h8naf5ydzmix15ssqi9q-x4 (derivation '/nix/store/6nr7k44hwkncbp5pq46grzqa8vcjnrm4-x4.drv') failed to build

@grahamc
grahamc requested a review from edolstra as a code owner April 29, 2025 15:29
Comment thread src/libstore/build/derivation-goal.cc Resolved
Comment thread src/libstore/build/derivation-goal.cc Resolved
nrFailed, worker.store.printStorePath(drvPath)));
(nrFailed == 1
? "%s dependency of %s (derivation '%s') failed to build"
: "%s dependencies of %s (derivation '%s') failed to build"

@edolstra edolstra Apr 30, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe a bit pedantic, but this message is incorrect: the failing path is not necessarily a dependency of the output (i.e. part of its closure). It could be a build-time dependency only, or it could be a runtime dependency of one of the other outputs.

A more accurate message: %s dependencies of derivation '%s' (outputs: ...) failed to build.

describer = worker.store.printStorePath(*firstOutput);
} else {
describer = drv->name;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of one arbitrary output, we could also print all outputs (concatStringsSep(", ", worker.store.printStorePathSet(outputs))).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another thing to consider is the CA derivation case, where we don't know the output paths in advance. We could ignore that for now though, since it's still experimental.

@grahamc

grahamc commented May 7, 2025

Copy link
Copy Markdown
Member Author

Closing in favor of a reimplementation.

@grahamc grahamc closed this May 7, 2025
@grahamc
grahamc deleted the push-uoyzlsnlusvu branch May 8, 2025 20:03
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.

3 participants