Switching to fish shell after running installer with zsh breaks PATH?
I have a macOS system, and am using this Nix template, which uses the Determinate Systems Nix installer =). (Disclaimer: I'm a Nix newbie - but I really wanted a declarative configuration for my machine, so here I am =)...)
However, I use fish as my shell, and am having all manner of issues getting the fish path to work correctly with Nix.
I ran the installer was run with the default macOS zsh shell (since the plan was to install fish using Nix - so that all of the installation of packages and configuration could be done deterministically with Nix - so I basically wanted to run the installer from a basically untouched macOS system).
However, I'm now trying to use home-manager to configure fish, with atuin etc - and I get the following error messages whenever I open a new terminal with fish as the default shell. (Calling fish from within a zsh shell works - but I'm guessing that's because fish is inheriting the PATH environment variables from zsh).
Last login: Tue Jul 16 22:17:15 on ttys004
fish: Unknown command: atuin
- (line 1):
atuin uuid
^~~~^
in command substitution
called on line 1 of file -
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
- (line 1): Unknown command
set -gx ATUIN_SESSION (atuin uuid)
^~~~~~~~~~~^
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
I did try adding the following to my home-manager configuration - however, this did not fix the errors:
fish = {
enable = true;
loginShellInit = ''
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish ]]; then
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
source /nix/var/nix/profiles/default/etc/profile.d/nix.fish
fi
'';
};
I saw from these earlier issues that fish support was added to both the NixOS official installer, and the Determinate Systems Nix installer quite some time back:
- https://github.com/NixOS/nix/issues/1512
- https://github.com/NixOS/nix/pull/7014
- https://github.com/DeterminateSystems/nix-src/commit/8ebdbeb2574ab3a8b6dbd9826451d9f26ca5ad3e
However, I'm guessing possibly my issue is caused by invoking the Nix installer from the default zsh shell, rather than installing fish first, is that right?
Is there some way of fixing it, so that the fish shell works properly with Nix?
Does anything change if you run fish via env __HM_SESS_VARS_SOURCED= fish? What about env __ETC_PROFILE_DONE= fish? What about combining them to get env __HM_SESS_VARS_SOURCED= __ETC_PROFILE_DONE= fish?
Thanks for getting back to me!
If fish is set as my default shell - when I try to run those commands - it complains about fish not being in my path...lol:
❯ env __ETC_PROFILE_DONE= fish
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ __ETC_PROFILE_DONE=\ fish'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ __ETC_PROFILE_DONE=\ fish'
in event handler: handler for generic event “fish_preexec”
env: fish: No such file or directory
However, I gave it the full path to the fish shell - hopefully this is still useful - and then printed the PATH variable:
❯ env __HM_SESS_VARS_SOURCED= /Users/foobar/.nix-profile/bin/fish
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ __HM_SESS_VARS_SOURCED=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ __HM_SESS_VARS_SOURCED=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
PATH before initialisation > /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
fish: Unknown command: atuin
- (line 1):
atuin uuid
^~~~^
in command substitution
called on line 1 of file -
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
- (line 1): Unknown command
set -gx ATUIN_SESSION (atuin uuid)
^~~~~~~~~~~^
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
~
❯ env | grep PATH
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
PATH=/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
And here is the second command, with the PATH:
❯ env __ETC_PROFILE_DONE= /Users/foobar/.nix-profile/bin/fish
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ __ETC_PROFILE_DONE=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ __ETC_PROFILE_DONE=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
PATH before initialisation > /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
fish: Unknown command: atuin
- (line 1):
atuin uuid
^~~~^
in command substitution
called on line 1 of file -
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
- (line 1): Unknown command
set -gx ATUIN_SESSION (atuin uuid)
^~~~~~~~~~~^
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
~
❯ env | grep PATH
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
PATH=/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
And then combining the two of them:
❯ env __HM_SESS_VARS_SOURCED= __ETC_PROFILE_DONE= /Users/foobar/.nix-profile/bin/fish
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ __HM_SESS_VARS_SOURCED=\ __ETC_PROFILE_DONE=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ __HM_SESS_VARS_SOURCED=\ __ETC_PROFILE_DONE=\ /Users/foobar/.nix-profile/bin/fish'
in event handler: handler for generic event “fish_preexec”
PATH before initialisation > /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
fish: Unknown command: atuin
- (line 1):
atuin uuid
^~~~^
in command substitution
called on line 1 of file -
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
- (line 1): Unknown command
set -gx ATUIN_SESSION (atuin uuid)
^~~~~~~~~~~^
from sourcing file -
called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
~
❯ env | grep PATH
fish: Unknown command: atuin
- (line 1):
atuin history start -- "$argv[1]"
^~~~^
in command substitution
called on line 6 of file -
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
- (line 6): Unknown command
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '_atuin_preexec' with arguments 'env\ \|\ grep\ PATH'
in event handler: handler for generic event “fish_preexec”
PATH=/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS
Does the above tell you anything useful?
Hi,
just stumbled upon this as I ran into what looked like the same issue. Though, since I'm using nix-darwin and am not familiar with the project here and while I'm hoping it'll help you, it could be useless for you.
nix-darwin Configuration Options exposes programs.fish.enable. Turning it on fixed the issue for me
The installer checks for presence of Fish directories to decide whether to create the setup config files.
If Fish will be installed after Nix, the simplest solution is to mkdir -p /usr/local/share/fish before running the installer.
Oh that is a super useful tip!!!!
Is that documented somewhere?
I don't think it is, I had to look at what the installer was doing. I think this could be improved.