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

Immediate error context should be shown without --show-trace #6031

Closed
lilyball opened this issue Feb 1, 2022 · 2 comments
Closed

Immediate error context should be shown without --show-trace #6031

lilyball opened this issue Feb 1, 2022 · 2 comments
Labels

Comments

@lilyball
Copy link
Member

lilyball commented Feb 1, 2022

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

  1. Use a module system such as NixOS or nix-darwin
  2. Declare an argument on a module that doesn't actually exist
  3. 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

@lilyball lilyball added the bug label Feb 1, 2022
@stale stale bot added the stale label Aug 1, 2022
@layus
Copy link
Member

layus commented Oct 18, 2022

Could be fixed by #6200

@Artturin
Copy link
Member

Artturin commented Jan 3, 2023

#6204 merged

@Artturin Artturin closed this as completed Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants