-
-
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
Print the value in error: cannot coerce
messages
#9553
Print the value in error: cannot coerce
messages
#9553
Conversation
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.
What a great, simple fix for such an old issue.
Please add a release note to celebrate.
83690bb
to
c60e63e
Compare
Added a release note! |
This extends the `error: cannot coerce a TYPE to a string` message to print the value that could not be coerced. This helps with debugging by making it easier to track down where the value is being produced from, especially in errors with deep or unhelpful stack traces.
c60e63e
to
07f6179
Compare
I think this broke the Clang on Linux build. #9564 hopefully fixes it. |
I just wanted to say thank you for this in the name of many people! Tiny change but it will have big impact. |
This reverts commit f0ac2a3. The request from the sibling PR, which also applies here, was not addressed. NixOS#9554 (comment)
Sorry, we had a miscommunication among the team. |
It's really a shame that this incredibly useful UX improvement was reverted so quickly when solutions were being developed to address the potential UX regression. :/ While I understand the procedure, etc. I do not think this is very encouraging to new contributors of the Nix codebase, especially when I don't see what's the harm of having a UX regression on the master branch sitting while it's being fixed, it's not like master Nix is being consumed by end users AFAIK. |
As I've already indicated, it's just procedure, and not a statement of value.
Uncertainty, a need more processes, perhaps even unfairness, but I really don't want to go into detail on that.
Also the blame is on us for merging prematurely. @9999years did nothing wrong. Let's not make this discussion any longer than it needs to be and focus on improving Nix. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-12-08-nix-team-meeting-minutes-110/36721/1 |
@roberth You didn't really explain why printing too much text is considered a UX regression, though, especially relative to the baseline. Certainly it can be annoying to scroll through, but is it more annoying than having an error message which gives no useful information? I responded to your comment on #9554 here, but instead of replying you just reverted my PR here, with seemingly no input from the other team members. In fact, making changes with no discussion seems to be a theme for Nix team members. It seems like a lot of the "process" is ad-hoc, undocumented, and behind closed doors, as this is now the second time a change of mine has led to a hasty addition to contribution guidelines to justify its rejection. It's intensely discouraging to attempt to make contributions that conform to rules I don't have access to. I like Nix, but I don't feel like my contributions are welcome here and after these experiences I'm rather hesitant to try again. Why should I spend my time preparing another patch when it seems like most PRs that don't come from Nix insiders linger without reviews or get bikeshedded for months or years? |
@9999years There was potential for non-termination, and other errors hiding the root cause. We've had regressions in error reporting before, so I wanted to prevent a situation where problems linger again. The Nix maintainer team has only existed for about a year now. We are trying to recover from a large and old backlog, while also trying to make progress in important areas for which external contributions are not made. We are still documenting and improving our process, and we'll discuss this with the team.
They are! They really are. There's a lot more to respond to here, but I'm afraid I'll have to do so later. |
I'd like to add to it that adding process documentation is something we happened to have picked up in a more consistent fashion somewhat recently, exactly to avoid that kind of frustration for contributors. We're very much aware that documentation is lacking and some things appear to be happening behind closed doors (that's certainly not on purpose, there is nothing to hide here). I very much want to change that, this is why we publish all meeting notes for example. So this is definitely not about your particular contributions, which I personally find extraordinarily valuable. This is not the first instance where we exercised an elevated degree of asynchronous decision making that didn't run smoothly. I still think that's better than what we had a year ago, where barely any decisions were made at all, leading to a large number of stalled PRs, or half a year ago, where we made most decisions in real-time meetings that were very limited in throughput. @roberth is right to raise stability and usability considerations, and we have to balance those conflicting interests of getting more contributions accepted, keeping maintainer workload in check, and providing a solid basis for the ecosystem to build upon; all in order to keep the project sustainable for everyone involved. A last thought that was raised recently in discussions with @zimbatm, @infinisil, and others: Ideally we'd just merge quickly and fix forward ourselves, or fix the issues we highlight in place. It would definitely improve contributor experience a great deal (although I've seen enough instances and experienced it myself that the things you wrote being changed underneath you can be just as frustrating as a revert). And we've been trying that out in the documentation team. But given the number of contributions and the change-compile-test turnaround time on the Nix codebase, generally this is simply unrealistic given our availability. We need more capacity and more work on infrastructure and are working towards that, but it all boils down to resources that mostly have to come from the community in one form or another. You're already donating time and that's great, thank you very much. Please be patient. 🙂 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/whats-nixs-stable-api-is-code-in-nix-instantiate-part-of-it/37986/1 |
Motivation
This extends the
error: cannot coerce a <TYPE> to a string
message to print the value that could not be coerced. This helps with debugging by making it easier to track down where the value is being produced from, especially in errors with deep or unhelpful stack traces.Context
See #561.
Here's an example of a mistake I made that would have been much easier to fix with this patch. I encountered this error while converting a NixOS configuration that relied on
builtins.currentSystem
to work in a flake. There were several overlays which pinned packages to specific versions, like this:My first try added an
inherit (config.nixpkgs) localSystem;
to theimport
arguments, but that gave me an unhelpful error:Note that the stack trace and error message don't make it clear which set couldn't be coerced to a string, or where the coercion failed. It's fairly easy to figure out what's gone wrong here, but in a repository with 14kloc it was significantly more difficult.
With this patch, the error message makes it clear what's happened (a system attrset has been used in place of a system string), and how to fix it (select the
system
attribute fromconfig.nixpkgs.localSystem
):Priorities
Add 👍 to pull requests you find important.