nix upgrade-nix reliably removes Lix from the default profile #1060

Open
opened 2025-12-01 20:02:00 +00:00 by rbt · 3 comments
Owner

Describe the bug

New with 2.94.

When I run sudo nix upgrade-nix, the uninstall works fine but the install fails, leaving me without any Nix available:

uninstalling 'lix-2.94.0'
installing 'lix-2.94.0'
error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly

Steps To Reproduce

$ which nix
/nix/var/nix/profiles/default/bin/nix

$ sudo nix upgrade-nix \
          --extra-substituters https://cache.lix.systems \
          --extra-trusted-public-keys 'cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o='
warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
downloading 'https://releases.lix.systems/manifest.nix'warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
uninstalling 'lix-2.94.0'
warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
installing 'lix-2.94.0'
error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly
error: program '/nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0/bin/nix-env' failed with exit code 1

$ nix
fish: Unknown command: nix
fish:
command nix
        ^~^

Fix the install like this, big thanks to @jade for helping write this command (the store path may need to be changed for non-aarch64-darwin systems, see https://releases.lix.systems/lix/lix-2.94.0/manifest.nix):

 sudo /nix/var/nix/profiles/per-user/root/profile/bin/nix-env \
    --extra-substituters https://cache.lix.systems \
    --extra-trusted-public-keys 'cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=' \
    --store local \
    --profile /nix/var/nix/profiles/default \
    -i /nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0

Expected behavior

Lix version is unchanged because there's nothing new to install (in fact, I would expect nix upgrade-nix to realize the new version and old version are the same store path and no-op).

nix --version output

$ nix --version
nix (Lix, like Nix) 2.94.0
System type: aarch64-darwin
Additional system types: x86_64-darwin
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /Users/wiggles/.config/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0/share
## Describe the bug New with 2.94. When I run `sudo nix upgrade-nix`, the uninstall works fine but the install fails, leaving me without any Nix available: ``` uninstalling 'lix-2.94.0' installing 'lix-2.94.0' error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly ``` ## Steps To Reproduce ``` $ which nix /nix/var/nix/profiles/default/bin/nix $ sudo nix upgrade-nix \ --extra-substituters https://cache.lix.systems \ --extra-trusted-public-keys 'cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=' warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root') downloading 'https://releases.lix.systems/manifest.nix'warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root') warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root') uninstalling 'lix-2.94.0' warning: $HOME ('/Users/wiggles') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root') installing 'lix-2.94.0' error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly error: program '/nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0/bin/nix-env' failed with exit code 1 $ nix fish: Unknown command: nix fish: command nix ^~^ ``` Fix the install like this, big thanks to @jade for helping write this command (the store path may need to be changed for non-`aarch64-darwin` systems, see https://releases.lix.systems/lix/lix-2.94.0/manifest.nix): ``` sudo /nix/var/nix/profiles/per-user/root/profile/bin/nix-env \ --extra-substituters https://cache.lix.systems \ --extra-trusted-public-keys 'cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=' \ --store local \ --profile /nix/var/nix/profiles/default \ -i /nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0 ``` ## Expected behavior Lix version is unchanged because there's nothing new to install (in fact, I would expect `nix upgrade-nix` to realize the new version and old version are the same store path and no-op). ## `nix --version` output ``` $ nix --version nix (Lix, like Nix) 2.94.0 System type: aarch64-darwin Additional system types: x86_64-darwin Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /Users/wiggles/.config/nix/nix.conf:/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/gxpdrn2sw1xpymxmsrxc7c706b7higws-lix-2.94.0/share ```
Owner

I think the design risk that causes this to happen is that we aren't creating a new profile and then calling nix-env --set on it, instead of doing in-place mutations with an invalid state in the middle.

FYI to anyone else hitting this, I got the store path from https://releases.lix.systems/lix/lix-2.94.0/manifest.nix

I think the design risk that causes this to happen is that we aren't creating a new profile and then calling `nix-env --set` on it, instead of doing in-place mutations with an invalid state in the middle. FYI to anyone else hitting this, I got the store path from https://releases.lix.systems/lix/lix-2.94.0/manifest.nix
Author
Owner

Yeah, agree we should create a new profile. The underlying error is weird too, haven't seen that one before: error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly.

Yeah, agree we should create a new profile. The underlying error is weird too, haven't seen that one before: `error: cannot open connection to remote store 'daemon': error: stream ended unexpectedly`.
Owner

We changed the behavior by default for privileged Nix operations, they don't use --store local by default anymore and tries to go over the daemon. It's very likely when you uninstall the Lix instance, the Lix daemon goes down suddenly, your local copy in-memory of Lix that is re-installing itself cannot talk anymore to a daemon and crashes as well.

upgrade-nix perhaps should prevent daemon connections to take place to avoid this situation.

We changed the behavior by default for privileged Nix operations, they don't use `--store local` by default anymore and tries to go over the daemon. It's very likely when you uninstall the Lix instance, the Lix daemon goes down suddenly, your local copy in-memory of Lix that is re-installing itself cannot talk anymore to a daemon and crashes as well. `upgrade-nix` perhaps should prevent daemon connections to take place to avoid this situation.
raito added this to the 2.95 milestone 2025-12-02 01:00:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 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#1060
No description provided.