-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Show stack trace above error message with innermost first #7334
Conversation
cc @bburdette |
128eee4
to
a6915c8
Compare
@edolstra @domenkozar @DavHau This is ready. I think it would be great to show the utmost trace / code location even without |
@chaoflow please add a brief description in the top post so the Nix team can slate this for review. Linking to an issue is good, but it requires clicking around, and we found it really helpful to see at a glance what the change is about why it is made. My personal note: I would like to see the rationale for the change in the commit messages, since GitHub issues and pull requests are practically inaccessible through Git history unless linked explicitly - and who knows how long they will exist. Writing those first and then re-using the text in the pull request description makes the above requirement trivial. |
a6915c8
to
1319b96
Compare
@fricklerhandwerk Thanks you for the feedback, I updated commit messages and PR description accordingly. |
Can you show a before and after here? |
before
after
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-40/23480/1 |
We noticed that To catch such things I did git grep -l 'makeDebugTraceStacker\|addErrorTrace\|addTrace' and I came up with this diff: 6a36e18. There is certainly more thing we ought to change, but I think this is sufficient to make this PR at least make nothing worse than today. I would be happy doing the rest in follow-up PRs. |
Triaged in Nix team meeting on 2022-11-25:
-> assigned to @fricklerhandwerk |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-11-25-nix-team-meeting-minutes-11/23601/1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in Nix team meeting 2022-11-28:
complete discussion
- @roberth:
at call site
is a regression because the grammar doesn't make sense any more in that order - @fricklerhandwerk: remove the attempt of imitating speech and make it a string of information bits
- it has to be readable in both directions, after all
- @Ericson2314: should merge this as is and open an issue fixing the presentation minutiae
- don't want to make author do ever more additional things and get frustrated in the process
- @fricklerhandwerk: this is again a UX issue which could be handled by experts much better
- we agree that the new order is obviously more suitable for finding the right information
Decision: @chaoflow This is good, only a few cosmetic fixups needed to improve readability. See the suggestions and please use @Ericson2314's diff to change the strings denoting the current action.
It should eventually look something like this, but we do this incrementally once this PR is merged:
❯ ../outputs/out/bin/nix --extra-experimental-features nix-command --extra-experimental-features flakes build
error: getting status of '/nix/store/qz0f0nw8siij1xw7cdk4n20xga6frhrs-source/broken/.version': No such file or directory
(use '--show-trace' to show detailed location information)
❯ ../outputs/out/bin/nix --extra-experimental-features nix-command --extra-experimental-features flakes build --show-trace
evaluation trace:
---
evaluating the derivation attribute 'name'
/nix/store/vp7k2rx0w0yidr691mmq62z6hragpbzx-source/pkgs/stdenv/generic/make-derivation.nix:278:7:
277| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
278| name =
| ^
279| let
---
evaluating call site
/nix/store/vp7k2rx0w0yidr691mmq62z6hragpbzx-source/pkgs/stdenv/generic/make-derivation.nix:295:9:
294| in
295| lib.strings.sanitizeDerivationName (
| ^
296| if attrs ? name
---
evaluating the attribute 'name'
/nix/store/qz0f0nw8siij1xw7cdk4n20xga6frhrs-source/broken/flake.nix:288:13:
287| nix = with final; with commonDeps { inherit pkgs; }; currentStdenv.mkDerivation {
288| name = "nix-${version}";
| ^
289| inherit version;
---
realising the context of path '/nix/store/qz0f0nw8siij1xw7cdk4n20xga6frhrs-source/broken/.version'
/nix/store/qz0f0nw8siij1xw7cdk4n20xga6frhrs-source/broken/flake.nix:12:17:
11|
12| version = builtins.readFile ./.version + versionSuffix;
| ^
13| versionSuffix =
---
getting status of '/nix/store/qz0f0nw8siij1xw7cdk4n20xga6frhrs-source/broken/.version': No such file or directory
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-11-28-nix-team-meeting-minutes-12/23730/1 |
Slightly off-topic, on the formatting of the stack trace, can be dealt with in another PR I have one concern with the suggested formatting in #7334 (review) : the blank lines and the I'd like to suggest something like this (slightly inspired from Rust's error trace):
I believe this format is easier to skim through with quick reading. |
@bew sure, we can still improve cosmetics. Maybe get in touch with @Ericson2314 who wanted to address this more generally.
Not sure what you mean. But I may be wrong and grossly misreading to code... |
I think he means the lack of spaces between the error location and the next 'evaluating' phrase could lead some folks to think they belong together. Here "evaluating call site" might be interpreted at first glance as belonging to the code above it.
With the format proposed by @bew, having a colon at the end of the 'evaluating' line would help reduce ambiguity about what belongs to what:
|
If there is some disagreement on what the best formatting is, then I recommend we just add 6a36e18, simplify the That keeps this PR just the uncontroversial stuff about traceback order along with the bare minimum changing the messages to not regress. |
Building on @bew 's proposal but reducing some whitespace:
|
@chaoflow I like this a lot. I'd only propose keeping capitalisation out, because it makes reshuffling information harder. We already noticed that assuming too much grammatical structure can be a hindrance to change. Would be great if you make that change, either here or in a follow-up PR (which I prefer because small changes are easier to review). |
@Ericson2314 thx - got it! Changing the loop entails a bit more work, will look at it later. |
6623c83
to
2e093ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much! This looks good to me now. The rest we can do in follow-up PRs.
Asking @roberth for a review since it was he that found those "from ..." messages that were the issue to begin with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build broke, please check again.
2e093ae
to
21974be
Compare
21974be
to
46a211b
Compare
When debugging nix expressions the outermost trace tends to be more useful than the innermost. It is therefore printed last to save developers from scrolling.
Save developers from scrolling by displaying the error message last, below the stack trace.
Make everything be in the form "while ..." (most things were already), and in particular *don't* use other propositions that must go after or before specific "while ..." clauses to make sense.
46a211b
to
8618c6c
Compare
Yay! @chaoflow you up for the reformatting follow-up PR now? |
@Ericson2314 Yes, happy to. |
Follow up: #7494 |
fixes #5278
When debugging nix expressions the outermost trace tends to be more useful
than the innermost. It is therefore printed last to save developers from
scrolling.
Same rationale for displaying the error message after the stack trace.