-
-
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
Improve error on conflict for nix profile install #7788
Improve error on conflict for nix profile install #7788
Conversation
This looks great to me in terms of the error message improvement, but I'll let those that know the codebase comment on the C++ bits. Thanks for improving this, it's quite a frustrating experience currently for devenv users to upgrade :) |
99a44d3
to
9b6b19b
Compare
777ad46
to
57b2d9b
Compare
I made some more changes so that the |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
@bobvanderlinden fair warning I don't yet have perms to merge this, but I can still shepherd along making it an easier approval for those that do. |
57b2d9b
to
7ece87f
Compare
@bobvanderlinden This is starting to look quite good! Thanks for doing this! Correct me if I am wrong, but Since it is for internal use only, and will always be caught, I think it would be also fine to just make it inherit |
7ece87f
to
dfa6f75
Compare
Ah you're right! That makes a lot of sense, thanks 👍 Updated the PR. |
Thanks @bobvanderlinden, this is very close to being ready! |
dfa6f75
to
bb863a3
Compare
Thanks for the quick reviews and suggestions. This improves my long forgotten C++ knowledge a bit too. 🥳 |
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.
In really like the informative error message, we can use lots more of that! Only suggestions on more concise wording from my side. Great work.
9481aa4
to
551e032
Compare
The test did show that I made a mistake with the Thanks you all for the suggestions. I've incorporated most of them and resolved the discussions. Quite a few improvements to the PR already 👍
Is this something I can look into for this PR? |
Better to do that in a followup, although it may make the testing story worse, as the layout becomes dependent on the length of the inputs. |
551e032
to
d186eb3
Compare
At the moment an Error is thrown that only holds an error message regarding `nix-env` and `nix profile`. These tools make use of builtins.buildEnv, but buildEnv is also used in other places. These places are unrelated to Nix profiles, so the error shouldn't mention these tools. This generic error is now BuildEnvFileConflictError, which holds more contextual information about the files that were conflicting while building the environment.
7cfd0b4
to
1fe5d17
Compare
I have reworked the implementation in this PR and left the tests as-is. I have removed Determining which file belongs to the original/new package is done entirely in This gives an implementation that doesn't run into sorting issues that I can into before. Bonus: the code is cleaner this way as well. |
Whenever a file conflict happens during "nix profile install" an error is shown that was previously thrown inside builtins.buildEnv. We catch BuildProfileConflictError here so that we can provide the user with more useful instructions on what to do next. Most notably, we give the user concrete commands to use with all parameters already filled in. This avoids the need for the user to look up these commands in manual pages.
1fe5d17
to
3efa476
Compare
Hmm, MacOS in CI failed to build due to usage of C++20 ranges. I guess a different version of clang is used on MacOS to build Nix? EDIT: The test failed again, this time because Nix in CI outputs a warning for running in offline mode, where-as locally that did not happen. I have opted for ignoring all |
@Ericson2314 I'll unsubscribe since the user-facing part is good, please continue with shepherding the implementation. |
Implementation looks good to me! |
Merging it then. |
Thank you all 🥳👍 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-team-report-2022-10-2023-03/27486/1 |
Motivation
Currently
nix profile install
gives a confusing and unhelpful error message whenever a package is installed that has conflicting files. This often happens when installing a different version of the same package.This PR is an attempt to improve the experience in such situations to some extend. I see this as a small improvement, but it doesn't really reach the end-goal of a good UX yet.
As an example, this is what happens before this PR:
This is what happens after this PR:
The new changes allows
nix profile install
to give more context.This also avoids mentions of
nix-env
andnix profile
when usingbuiltins.buildEnv
. SincebuildEnv
can be used in other places (unrelated to the Nix profile), it makes sense to avoid mentioningnix-env
andnix profile
, as they likely do not apply in these cases.Context
Related to #7530
See my suggestion for a good UX on
nix profile
s. The current PR is merely an improvement for the error message on conflicts.Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*