-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix nix upgrade-nix
profile search
#12048
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mergify rebase |
Commit cfe66db updated `nix upgrade-nix` to use `ExecutablePath::load().find`, which broke the logic for finding the profile associated with the nix executable. The error looks something like: ``` $ sudo -i nix upgrade-nix --debug found Nix in '"/nix/store/46p1z0w9ad605kky62dr53z4h24k2a5r-nix-2.25.2/bin/nix"' found profile '/nix/store/46p1z0w9ad605kky62dr53z4h24k2a5r-nix-2.25.2/bin' error: directory '"/nix/store/46p1z0w9ad605kky62dr53z4h24k2a5r-nix-2.25.2/bin/nix"' does not appear to be part of a Nix profile ``` This seems to happen for two reasons: 1. The original PATH search resulted in a directory, but `find` returns the path to the executable. Fixed by getting the path's parent. 2. The profile symlink cannot be found because `ExecutablePath::load().find` canonicalizes the executable path. I updated find to normalize the path instead, which seems more in line with how other programs resolve paths. I'm not sure if this affects other callers though. I manually tested this on macOS and Linux, and it seemed to fix upgrading from 2.25.2 to 2.25.3.
✅ Branch has been successfully rebased |
Mic92
force-pushed
the
fix-upgrade-nix
branch
from
December 14, 2024 15:28
2452621
to
4f831e2
Compare
the format error already adds quotes.
Mic92
added
the
backport 2.25-maintenance
Automatically creates a PR against the branch
label
Dec 15, 2024
@mergify queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 3663480 |
27 tasks
mergify bot
added a commit
that referenced
this pull request
Dec 15, 2024
…2048 Fix `nix upgrade-nix` profile search (backport #12048)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport 2.25-maintenance
Automatically creates a PR against the branch
bug
new-cli
Relating to the "nix" command
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I could no longer get
nix upgrade-nix
to work on macOS or Linux after upgrading to 2.25:Fix the profile search logic so that it works again without needing to explicitly give
--profile /nix/var/nix/profiles/default
.Context
Commit cfe66db (in #11218) updated
nix upgrade-nix
to useExecutablePath::load().find
, which broke the logic for finding the profile associated with the nix executable. This seems to happen for two reasons:find
returns the path to the executable. Fixed by getting the path's parent.ExecutablePath::load().find
canonicalizes the executable path. I updated find to normalize the path instead, which seems more in line with how other programs resolve paths. I'm not sure if this affects other callers though.I manually tested this on macOS and Linux, and it seemed to fix upgrading from 2.25.2 to 2.25.3.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.