Skip to content
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

Nix install script instructions for removing old Nix version may need to include /Library/LaunchDaemons/org.nixos.nix-daemon.plist in deletion list #4860

Closed
byrongibson opened this issue May 31, 2021 · 4 comments
Labels

Comments

@byrongibson
Copy link

byrongibson commented May 31, 2021

Describe the bug

This is a minor issue. When installing Nix on a Mac (Mojave 10.14.6 in this case) with a prior version of Nix, the Nix install script requires you first delete the old installation. It provides instructions for doing this:

  1. Reset /etc/bashrc to its prior version before Nix was installed.
  2. Reset /etc/zshrc to its prior version before Nix was installed.
  3. Delete the following:

sudo rm -rf /etc/nix /nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels /Users/byron/.nix-profile /Users/byron/.nix-defexpr /Users/byron/.nix-channels

Step #3 is incomplete, and the install will still fail if you don't also delete the file /Library/LaunchDaemons/org.nixos.nix-daemon.plist. The error it gives if you haven't deleted that file is:

---- sudo execution ------------------------------------------------------------
I am executing:

$ sudo cp -f /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist /Library/LaunchDaemons/org.nixos.nix-daemon.plist

to set up the nix-daemon as a LaunchDaemon

cp: /Library/LaunchDaemons/org.nixos.nix-daemon.plist and /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist are identical (not copied).

---- oh no! --------------------------------------------------------------------
Jeeze, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.

:(

We'd love to help if you need it.

If you can, open an issue at https://github.com/nixos/nix/issues

Or feel free to contact the team,

  • on IRC #nixos on irc.freenode.net
  • on twitter @nixos_org

Steps To Reproduce

run sh install-nix-2.3.11 --daemon on a Mac without having first deleted /Library/LaunchDaemons/org.nixos.nix-daemon.plist.

Expected behavior

Expected behavior is for the install script to finish without error.

nix-env --version output

nix-env (Nix) 2.3.11

Additional context

Nix install script directions for removing an old Nix version:

---- oh no! --------------------------------------------------------------------
There are some relics of a previous installation of Nix at /nix, and
this scripts assumes Nix is not yet installed. Please delete the old
Nix installation and start again.

Uninstalling nix:

  1. Restore /etc/bashrc.backup-before-nix back to /etc/bashrc

sudo mv /etc/bashrc.backup-before-nix /etc/bashrc

(after this one, you may need to re-open any terminals that were
opened while it existed.)

  1. Restore /etc/zshrc.backup-before-nix back to /etc/zshrc

sudo mv /etc/zshrc.backup-before-nix /etc/zshrc

(after this one, you may need to re-open any terminals that were
opened while it existed.)

  1. Delete the files Nix added to your system:

sudo rm -rf /etc/nix /nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels /Users/me/.nix-profile /Users/me/.nix-defexpr /Users/me/.nix-channels

and that is it.

@abathur
Copy link
Member

abathur commented May 31, 2021

The currently-released installer ~should have printed a first step directing you to remove the plist before the instructions you describe--but only if the file exists.

This check is fairly straightforward, so I'm skeptical that it wouldn't have printed if the file was present.

Can you confirm whether the instruction printed on the initial run? If you ran the installer again after removing the plist, the instruction wouldn't show.

(The current installer does have some unfortunate gotcha conditions--it's possible to run the installer, hit a failure, remove the files that caused the failure, and re-run only to have it fail again because of files it added before the previous failure. I have a thread open on discourse (https://discourse.nixos.org/t/anyone-up-for-picking-at-some-nix-onboarding-improvements/13152) fishing for help with a project that would ~fix this problem, but no bites so far.)

I spot-checked the behavior of the check that gates this and don't see anything unexpected. If you can verify it wasn't present, we may need your help investigating the behavior of poly_service_installed_check by confirming [ -e "/Library/LaunchDaemons/org.nixos.nix-daemon.plist" ]; echo $? prints 0 when /Library/LaunchDaemons/org.nixos.nix-daemon.plist exists and 1 when it doesn't?

@byrongibson
Copy link
Author

byrongibson commented Jun 1, 2021

it's possible to run the installer, hit a failure, remove the files that caused the failure, and re-run only to have it fail again because of files it added before the previous failure.

I suspect this may have been what happened. I ran the installer several times and it failed b/c I didn't restore the old bashrc and zshrc properly. Once I did that, the next error was the one I reported above. Then after fixing all three errors, the install completed successfully without further error.

If it looks ok to you then it probably is. Though, is there any downside to including that plist file in the rm -rf instruction? That would have saved me one or two extra attempts.

@abathur
Copy link
Member

abathur commented Jun 1, 2021

No good reason :)

Fixing this problem (both by adding an --uninstall flag and making sure the installer doesn't faceplant when these files are in the way in the first place) is a primary goal of the project/thread I mentioned previously. It'll be a bit before I have bandwidth to undertake it myself if no one else steps up--but I hope I can get to it this year.

The existing behavior mainly comes down to how the Linux and macOS-specific installer variants work (and how difficult working on the installer has been, historically--but that situation improved a lot in March). There's a core script, with platform-specific functions in each platform-specific script. They get their chance to list all platform uninstall steps before the general steps.

@byrongibson
Copy link
Author

Thanks. As I said, it's a minor issue, and the error messages were sufficient to figure it out. Not a high priority, just wanted to report it as the installer instructed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants