You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invoking nix build against a string containing a store path causes sadness: it does not build anything and returns an error seemingly nothing to do with the actual problem.
Steps To Reproduce
Put this in a file:
let
Caddyfile-formatted = builtins.derivation { system = "x86_64-linux"; name = "test"; builder = "/bin/sh"; args = ["-c" "> $out" ]; };
in
"${Caddyfile-formatted}/Caddyfile"
nix build -f ./bug.nix
error:
… while evaluating the attribute ''
at «none»:0: (source not available)
error: string '/nix/store/nfb1lb8dd7wxn0g9cccq2a9zf8dk219a-test/Caddyfile' has context with the output 'out' from derivation '/nix/store/qvryn0lpyyizpqn55i9fdklb5l3d97b6-test.drv', but the string is not the right placeholder for this derivation
output. It should be '/nix/store/nfb1lb8dd7wxn0g9cccq2a9zf8dk219a-test'
Expected behavior
I expected the error message to be less bad, for example, what nix-build bug.nix does:
error: expression does not evaluate to a derivation (or a set or list of those)
although I will note that that error is also terrible, but for different reasons: it doesn't do the thing you want. The case I had here is that I needed to nix eval some string, and then build the derivation from it. I took the store path in the string and gave it to nix build, but it couldn't identify the derivation file necessary to build it.
nix-env --version output
nix-env (Nix) 2.18.1
Additional context
This occurred in practice while trying to get something out of a NixOS config under environment.etc.something.source.
The error should then also be improved to point out that this feature exists.
I think the new behavior should only be enabled when explicitly requested; otherwise things get very ambiguous when the wrong behavior is activated by mistake.
Describe the bug
Invoking
nix build
against a string containing a store path causes sadness: it does not build anything and returns an error seemingly nothing to do with the actual problem.Steps To Reproduce
Put this in a file:
nix build -f ./bug.nix
Expected behavior
I expected the error message to be less bad, for example, what
nix-build bug.nix
does:although I will note that that error is also terrible, but for different reasons: it doesn't do the thing you want. The case I had here is that I needed to
nix eval
some string, and then build the derivation from it. I took the store path in the string and gave it tonix build
, but it couldn't identify the derivation file necessary to build it.nix-env --version
outputAdditional context
This occurred in practice while trying to get something out of a NixOS config under
environment.etc.something.source
.Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: