Nix install with curl fails if /nix already exists

The first time installing with curl | sh works fine (asks for sudo), but if we run it a second time it will fail with permission denied when trying to access /nix and it doesn’t prompt for sudo in the second case.

I was trying to start from scratch, to see if I could avoid the duplicate search issue, so I delete all ~/.nix-* folders and tried the curl command again, then got permission denied.

I deleted the /nix folder then I was able to try again successfully.

Maybe a better error message should be thrown in this case, or maybe it should just ask for sudo again and do what it needs to do?

AFAIK the install script just uses sudo every time, and you only get prompted once because sudo caches credentials for 5 minutes within a given shell session (by default).

@lilyball The problem is if /nix already exists in the filesystem before running curl | sh, then the install script does not attempt to use sudo and it fails when it tries to do anything with the /nix folder.

Opened an issue for it at