-
-
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
M1 Mac reinstall -- -bash: nix-shell: command not found
#5298
Comments
@toonn you had an uninstallation gist somewhere? |
Short of fully uninstalling and reinstalling (whether via a gist from toon, or via iterative masochism...), I guess the other option is just logically stepping through and debugging things. Some ~starting thoughts:
|
Thanks for your help!
Isn't that what I'm doing? That's what I'm aiming for, and I'm following the official uninstall process AFAICT.
Yes, as noted it exists and I am manually sourcing it just to be sure (thought it's also in my
This is not working. $ source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && echo "$PATH" | grep -i nix || echo "not found"
not found
As a less spammy alternative, I just added the following to my if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
echo "$PATH" | grep -i nix || echo "not found"
fi That should mean that |
Here's the Gist but I think you're getting everything relevant, only missing the build users but they shouldn't interfere with a reinstall. Maybe EDIT: I'd missed that second LaunchDaemon you found btw, thanks : ) |
I'm sourcing it manually with no change. I've also added a few debug Ok, I think I'm on to something -- the problem is:
I do override But it looks like on a multi-user build, it's sourcing |
Yup, that seems to be the issue. In my Sourcing I think I should be able to sort out a workaround, though I wonder if less surprising mechanism than |
Here's my workaround, put in my # Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
# if PATH does *not* contain `~/.nix-profile/bin`
if [ -n "${PATH##*.nix-profile/bin*}" ]; then
# If this flag is set, `nix-daemon.sh` returns early
# https://github.com/NixOS/nix/issues/5298
unset __ETC_PROFILE_NIX_SOURCED
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
fi
# End Nix Fixed. $ nix-env --version
nix-env (Nix) 2.3.15 Thanks again! |
This discussion prompted me to evaluate my own By the way, @n8henrie, you wrote:
I do something similar, but for other reasons. Nevertheless, it sounds like you want to use a general |
This was interfering with the Nix install path. See conversation: NixOS/nix#5298
For those also using nix-darwin, nix-darwin uses Unfortunately, if you just
To work around all this (without my PATH growing longer and longer), I initially tried putting a
This was taking ~5ms on my machine. Eventually, I figured out that a likely more robust / future-proof method would be to just spawn a clean subshell, source EDIT: Resetting the enivornment unfortunately meant that
It looks like this adds roughly the same amount of time, perhaps just a smidge faster
Also, please note that I am appending the nix path to the end of my path: EDIT: Alternatively, I suppose I could replace my EDIT2: For some reason EDIT1 doesn't work; MacOS is persisting the relevant environment variables even when I completely close out tmux, kill all sessions, and close out Terminal.app, so that nothing is re-sourced with a new shell. I don't get it. |
A little oblique, but I've been trying to think out loud about improvements when opportunities present:
|
Describe the bug
I had a previous single-user install. I couldn't get nix-darwin working, so I wanted to retry with a multi-user install. After an uninstall and reinstall, when I try
nix-shell -p nix-info --run "nix-info -m"
I get-bash: nix-shell: command not found
.I have confirmed that I am sourcing
/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
and that the launchdaemon is running.Steps To Reproduce
For uninstallation: https://nixos.org/manual/nix/stable/#sect-multi-user-installation
launchctl list | grep -i nix; sudo launchctl list | grep -i nix
showed a straggler, so I also added:Also, after my first few attempts I started adding the below to avoid issues in the installation step:
Afterwards, from https://nix.dev/tutorials/install-nix#macos:
Expected behavior
Installation process at https://nix.dev/tutorials/install-nix#macos and https://nixos.org/manual/nix/stable/#sect-multi-user-installation to result in a working installation.
nix-env --version
outputAdditional context
I ran
diff /etc/bashrc /etc/bashrc.backup-before-nix
and added the following to my~/.bashrc
to see if that would fix a suspectedPATH
issue:I can see several relevant envvars in
$ env | grep NIX
, but still command not found.It ends up on my path if I run:
Also works with
$ /opt/homebrew/bin/bash --noprofile --norc
, or withsudo su
, sourcing thenix-daemon.sh
afterward each time, so it's obviously a problem with my local configuration. It doesn't work withsudo /bin/bash
, so it seems less likely to be a permission / root profile thing. I think.I thought it might be related to
~/.nix-profile
(which was deleted in the uninstall step) being a broken symlink;/nix/var/nix/profiles/per-user/n8henrie/profile
doesn't exist, only/nix/var/nix/profiles/per-user/root
, butsudo nix-env --version
also doesn't work, and when I use the--noprofile --norc
workaround, it is still a symlink to nowhere.Trying to pick through the MacOS threads at https://discourse.nixos.org/t/anyone-up-for-picking-at-some-nix-onboarding-improvements/13152/6, not much luck yet.
Searching the issues shows a lot of open / unresolved / marked stale problems with MacOS. The most relevant handful I've found:
The text was updated successfully, but these errors were encountered: