Skip to content

Commit

Permalink
local-derivation-goal: improve "illegal reference" error
Browse files Browse the repository at this point in the history
Before the change "illegal reference" was hard to interpret as it did
not mention what derivation actually hits it.

Today's `nixpkgs` example:

Before the change:

    $ nix build --no-link -f. postgresql_14
    ...
    error: derivation contains an illegal reference specifier 'man'

After the change:

    $ nix build --no-link -f. postgresql_14
    ...
    error: derivation '/nix/store/bxp6g57limvwiga61vdlyvhy7i8rp6wd-postgresql-14.15.drv' output 'lib' contains an illegal reference specifier 'man', expected store path or output name (one of [debug, dev, doc, lib, out])
  • Loading branch information
trofi committed Dec 25, 2024
1 parent f72752c commit 4afd6f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libstore/unix/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2927,8 +2927,17 @@ void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo
spec.insert(worker.store.parseStorePath(i));
else if (auto output = get(outputs, i))
spec.insert(output->path);
else
throw BuildError("derivation contains an illegal reference specifier '%s'", i);
else {
std::string allOutputs;
for (auto & o : outputs) {
if (! allOutputs.empty())
allOutputs.append(", ");
allOutputs.append(o.first);
}
throw BuildError("derivation '%s' output '%s' contains an illegal reference specifier '%s',"
" expected store path or output name (one of [%s])",
worker.store.printStorePath(drvPath), outputName, i, allOutputs);
}
}

auto used = recursive
Expand Down

0 comments on commit 4afd6f5

Please sign in to comment.