Derivation with empty outputs gets an uncharacteristic error message #1142
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
awaiting
author
awaiting
contributors
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
Importance
High
Importance
Low
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
Release Blocking
Non-urgent
Release Blocking
Urgent
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
Urgency
High
Urgency
Low
ux
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#1142
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Derivation with empty outputs should receive a clear message that the output list is empty and should contain something.
Instead, we get:
Problem is that we need to decide if the error is fatal or not, it is currently is. If we throw an abort from the builtin, it's also meh. If we throw a catchable error, well… it's now catchable!
All (strong) opinions welcome.
cc @pennae
I'd argue to keep it as a catchable error, but definitely with a better error message, e.g. "derivations must define at least one output", though this isn't a strong opinion
three notes:
derivationStrictalready has an error for this (derivation cannot have an empty set of outputs.) and it is an eval error that is not catchablebuiltins.derivationis defined inlibexpr/primops/derivation.nix(and callsderivationStrict, tho it actually doesn't get eval'd whenoutputsis empty) and does theheadcall that causes this errorlibexpr/imported-drv-to-derivation.nixthat (if i'm not mistaken) is used when doing IFD to a.drvfile's attrs to aderivation, which means it'll probably never have to encounter an emptyoutputsarray, but it could be a nice precaution to handle it anywayfor what it's worth, i do think it should be catchable, and it'd be a nice opportunity to changeafter discussing it with @raito and @piegames, i'm mostly trending towards non-catchable, though that isn't a very strong opinion. if anyone else has opinions, please don't hesitate to put them here, the debate still has to be had :)derivationStrict's error to also be catchablethe debate very quickly turned into a general "should most errors even exist/be catchable in nix," with the main points being:
builtins.tryEval(the only thing really influenced by fatal vs. non-fatal) is mostly used in CI and non-interactive scenarios. Generally, this will be to allow getting some information about a package set and each derivation within it, including for multiple build/runtime contexts (architecture, libc, etc.). There are a lot of scenarios where we want to be able to partially evaluate those derivations, get some info about them, even if they aren't fully formed, and use it to create new data/derivations.nix evalvariant or option)tryEvalby marking it as unsafe and impure, virtually excluding it from any code that is meant to produce derivations (which is generally pure)builtins.elemAtthrowing an uncatchable exception) can be annoying in nix, and there could be some design space to explore thereand a final note from @raito: at the end of the day, the general catchability debate is limited by the small number of scenarios we know of where catching this type of error is actually useful, especially outside of a CI/hydra context. ultimately, we need to gather experiences from a wider range of people and to get more debate going.