-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
The Nixpkgs module system makes extensive use of builtins.addErrorContext. This is really helpful! But I don't get any of that info if I don't pass --show-trace. Instead I just get an error that points into the expression inside of the builtins.addErrorContext call.
I feel like usability here would be increased significantly if the error printing without --show-trace would still include the immediate error context if one exists. Which is to say, if showing the full trace would show a context added from builtins.addErrorContext as the next step, then go ahead and show that without --show-trace.
For example, I have an error right now that looks like
error: attribute 'inputs' missing
at /nix/store/fbcgjqs34vllzzppa1y213fbxx01sxn7-source/lib/modules.nix:386:28:
385| builtins.addErrorContext (context name)
386| (args.${name} or config._module.args.${name})
| ^
387| ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)
The location info here is not terribly helpful. If I pass --show-trace the very next entry in the trace is the error context
… while evaluating the module argument `inputs' in "/nix/store/kxhwfcng3hv8kzvzgwaaqv1pv6kspa88-source/common/home-manager/lily/default.nix":
This one extra line provides significant value and I wish I didn't have to pass --show-trace to see it.
Steps To Reproduce
- Use a module system such as NixOS or nix-darwin
- Declare an argument on a module that doesn't actually exist
- Evaluate your config
Expected behavior
The error should tell me where the bad argument is without having to use --show-trace.
nix --version output
nix (Nix) 2.5.1