[Nix#9962] Show the first few and last few stack frames by default #169

Open
opened 2024-03-24 02:02:11 +00:00 by lix-bot · 1 comment
Member

Upstream-Issue: NixOS/nix#9962

Is your feature request related to a problem? Please describe.
When an error is encountered and --show-trace hasn't been given, only the three outer-most stack frames are displayed. Often, these are not very useful. Here's the full text of an error I was asked to help diagnose at work:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'enter-shell'
         whose name attribute is located at /nix/store/ybwlqh43kz9cpccikrka6h2x44c98yf4-source/pkgs/stdenv/generic/make-derivation.nix:311:7

       … while evaluating attribute 'text' of derivation 'enter-shell'

         at /nix/store/ybwlqh43kz9cpccikrka6h2x44c98yf4-source/pkgs/build-support/trivial-builders/default.nix:148:16:

          147|     runCommand name
          148|       { inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          149|         passAsFile = [ "text" ];

       (stack trace truncated; use '--show-trace' to show the full trace)

It's likely that the inner-most couple stack frames contain the most useful information here, but they're not shown and non-expert Nix users don't understand enough of the information being presented in the first few frames to know they're all generic boilerplate code.

Describe the solution you'd like

Instead of showing the three outer-most stack frames, the first (perhaps?) two and last two should be shown instead.

Additional context

The stack frame printing logic was designed by @layus, who admits that the choice to print the first three frames was arbitrary:

09a6e8e703/src/libutil/error.cc (L297-L298)

While that logic has been more-or-less fine until now, I think adding the last few frames will increase the signal-to-noise ratio of Nix's error reports.

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9962 **Is your feature request related to a problem? Please describe.** When an error is encountered and `--show-trace` hasn't been given, only the three outer-most stack frames are displayed. Often, these are not very useful. Here's the full text of an error I was asked to help diagnose at work: ``` error: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:9:12: (source not available) … while evaluating derivation 'enter-shell' whose name attribute is located at /nix/store/ybwlqh43kz9cpccikrka6h2x44c98yf4-source/pkgs/stdenv/generic/make-derivation.nix:311:7 … while evaluating attribute 'text' of derivation 'enter-shell' at /nix/store/ybwlqh43kz9cpccikrka6h2x44c98yf4-source/pkgs/build-support/trivial-builders/default.nix:148:16: 147| runCommand name 148| { inherit text executable checkPhase allowSubstitutes preferLocalBuild; | ^ 149| passAsFile = [ "text" ]; (stack trace truncated; use '--show-trace' to show the full trace) ``` It's likely that the inner-most couple stack frames contain the most useful information here, but they're not shown and non-expert Nix users don't understand enough of the information being presented in the first few frames to know they're all generic boilerplate code. **Describe the solution you'd like** Instead of showing the three outer-most stack frames, the first (perhaps?) two and last two should be shown instead. **Additional context** The stack frame printing logic was designed by @layus, who admits that the choice to print the first three frames was arbitrary: https://github.com/NixOS/nix/blob/09a6e8e7030170611a833612b9f40b9a10778c18/src/libutil/error.cc#L297-L298 While that logic has been more-or-less fine until now, I think adding the _last_ few frames will increase the signal-to-noise ratio of Nix's error reports. **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
imported
label 2024-03-24 02:02:11 +00:00
Owner

Looks like we can steal roberth's implementation here: https://github.com/NixOS/nix/pull/10305

Looks like we can steal roberth's implementation here: https://github.com/NixOS/nix/pull/10305
jade added the
ux
label 2024-03-24 05:54:52 +00:00
jade added this to the v2.90 milestone 2024-03-24 05:54:58 +00:00
jade added this to the Release engineering project 2024-03-24 06:24:58 +00:00
jade removed this from the Release engineering project 2024-06-05 02:34:07 +00:00
jade modified the milestone from v2.90 to v2.91 2024-06-05 02:34:09 +00:00
jade modified the milestone from v2.91 to post-release 2024-08-13 01:19:35 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#169
No description provided.