DeterminateSystems / nix-installer

Install Nix and flakes with the fast and reliable Determinate Nix Installer, with over 7 million installs.
https://determinate.systems
GNU Lesser General Public License v2.1
2.21k stars 57 forks source link

Error after install on MacOS with fish shell (v0.24.0 installer) #1139

Closed crcastle closed 2 months ago

crcastle commented 2 months ago

It seems that the v0.24.0 MacOS installer using fish shell requires something called fenv. This is not a standard part of the fish shell, but it seems as though what is installed assumes it is.

It looks like the nix install is looking for this: https://github.com/oh-my-fish/plugin-foreign-env but I am not totally sure.

My fish shell version is 3.7.1.

❯ ./nix-installer-aarch64-darwin install
 INFO nix-installer v0.24.0
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
 INFO nix-installer v0.24.0
Nix install plan (v0.24.0)
Planner: macos (with default settings)

Planned actions:
* Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
* Extract the bundled Nix (originally from /nix/store/ahjjnaja9llx6dd8pd6hh6iiqlr86yqm-nix-binary-tarball-2.24.5/nix-2.24.5-aarch64-darwin.tar.xz)
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Create build users (UID 351-382) and group (GID 350)
* Configure Time Machine exclusions
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Configuring zsh to support using Nix in non-interactive shells
* Create a `launchctl` plist to put Nix into your PATH
* Configure upstream Nix daemon service
* Remove directory `/nix/temp-install-dir`

Proceed? ([Y]es/[n]o/[e]xplain): Y
 INFO Step: Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
 INFO Step: Provision Nix
 INFO Step: Create build users (UID 351-382) and group (GID 350)
 INFO Step: Configure Time Machine exclusions
 INFO Step: Configure Nix
 INFO Step: Configuring zsh to support using Nix in non-interactive shells
 INFO Step: Create a `launchctl` plist to put Nix into your PATH
 INFO Step: Configure upstream Nix daemon service
 INFO Step: Remove directory `/nix/temp-install-dir`
Nix was installed successfully!
To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish`

~/Downloads 43s
❯ fish: Unknown command: fenv
~/.config/fish/conf.d/nix.fish (line 2): 
  fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
  ^~~^
from sourcing file ~/.config/fish/conf.d/nix.fish
    called on line 248 of file /opt/homebrew/Cellar/fish/3.7.1/share/fish/config.fish
from sourcing file /opt/homebrew/Cellar/fish/3.7.1/share/fish/config.fish

Now every time I hit enter in my shell, I get the following error between command prompts:

❯ fish: Unknown command: fenv
~/.config/fish/conf.d/nix.fish (line 2): 
  fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
  ^~~^
from sourcing file ~/.config/fish/conf.d/nix.fish
    called on line 248 of file /opt/homebrew/Cellar/fish/3.7.1/share/fish/config.fish
from sourcing file /opt/homebrew/Cellar/fish/3.7.1/share/fish/config.fish
~
❯ 
crcastle commented 2 months ago

Installing https://github.com/oh-my-fish/plugin-foreign-env seems to have resolved the problem. Apologies if I missed somewhere that fenv was a requirement. If not, please add it to the docs!

cole-h commented 2 months ago

We don't place that file (~/.config/fish/conf.d/nix.fish), and the only shell profiles we install are from upstream which doesn't mentionfenv at all: https://github.com/NixOS/nix/blob/master/scripts/nix-profile-daemon.fish.in

Are you sure you're not using something like nix-darwin (or used it in the past)?

crcastle commented 2 months ago

Yep, prior use of nix-darwin was probably the culprit. It looks like I didn't notice it before using the nix installer because that fenv ... statement is enclosed within if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh', so prior to the /nix directory be (re)added, it never was executed.

Apologies for the false alarm. Closing.