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

Nix crashes when evaluating attribute sets which look like an invalid derivation #7383

Open
sir4ur0n opened this issue Dec 1, 2022 · 1 comment
Labels
bug error-messages Confusing messages and better diagnostics stale

Comments

@sir4ur0n
Copy link

sir4ur0n commented Dec 1, 2022

Describe the bug

Evaluating an attribute set like {name = "foo"; type = "derivation"; drvPath = "";} in the REPL crashes, rather than printing an error and giving back the REPL prompt.

Steps To Reproduce

$ nix repl
Welcome to Nix 2.8.1. Type :? for help.

nix-repl> {name = "foo"; type = "derivation"; drvPath = "";}
nix: src/libutil/util.cc:109: nix::Path nix::canonPath(nix::PathView, bool): Assertion `path != ""' failed.
[1]    921322 IOT instruction (core dumped)  nix repl
$ 

As you can see, the REPL session is killed, and the error message is not user-friendly.

Expected behavior

A user-friendly error like error: expression contains an empty 'drvPath' attribute., or even no error, because there is nothing wrong with this attribute set (until one tries to build it, of course).

nix-env --version output
nix-env (Nix) 2.8.1 but @rapenne-s confirmed it also happens on 2.11.

Additional context

FWIW the REPL behaves as expected when setting outPath = "";:

$ nix repl
Welcome to Nix 2.8.1. Type :? for help.

nix-repl> {name = "foo"; type = "derivation"; outPath = "";}
«derivation ???»

nix-repl>
@sir4ur0n sir4ur0n added the bug label Dec 1, 2022
@roberth
Copy link
Member

roberth commented Dec 10, 2022

Nix shouldn't need drvPath if it reads outputs and the output attrs instead. (#6507)
That said, this should already be an easy fix.

@roberth roberth added the error-messages Confusing messages and better diagnostics label Dec 10, 2022
@stale stale bot added the stale label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug error-messages Confusing messages and better diagnostics stale
Projects
None yet
Development

No branches or pull requests

2 participants