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

Switching to fish shell after running installer with zsh breaks PATH? #1053

Open
victorhooi opened this issue Jul 17, 2024 · 3 comments
Open
Labels
MacOS Darwin/MacOS

Comments

@victorhooi
Copy link

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:

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?

@cole-h
Copy link
Member

cole-h commented Jul 17, 2024

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?

@cole-h cole-h added the MacOS Darwin/MacOS label Jul 17, 2024
@victorhooi
Copy link
Author

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?

@pejaab
Copy link

pejaab commented Dec 28, 2024

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

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

No branches or pull requests

3 participants