nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.27k stars 1.68k forks source link

bug: Using fish and atuin - spawning new fish shell complains about atuin not in path? #5486

Open victorhooi opened 4 weeks ago

victorhooi commented 4 weeks ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I'm using this template as my starter for nix on my macOS system. Still learning a bit, so sorry if I'm not doing this the right way.

I've enabled both atuin and fish through my home-manager.nix file as follows:

  atuin = {
    enable = true;
    enableBashIntegration = true;
    enableFishIntegration = true;
  };
  fish = {
    enable = true;
  };

I didn't see anything in home-manager to set the default shell. Hence I added the fish shell to /etc/shells (it wasn't in there previously):

❯ cat /etc/shells 
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/Users/foobar/.nix-profile/bin/fish

And I also ran chsh to set it to fish:

❯ chsh -s /Users/foobar/.nix-profile/bin/fish
Changing shell for bytedance.
Password for bytedance: 

However, when I spawn a new shell (now with fish as the default shell) I get the following error:

Last login: Mon Jun  3 12:56:39 on ttys007
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

It seems to be some kind of path issue - but I'm not sure why it's happening, or if I've enabled atuin/fish the "correct' way for home-manager/nix.

Maintainer CC

@r-vdp @emilazy

System information

I'm sorry - when I try to run this, I get the following error:

❯ nix-shell -p nix-info --run "nix-info -m"
error:
       … while calling the 'import' builtin
         at «string»:1:18:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |                  ^

       … while realising the context of a path

       … while calling the 'findFile' builtin
         at «string»:1:25:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |                         ^

       error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
r-vdp commented 3 weeks ago

That's pretty weird.

What's the contents of your fish config file (~./config/fish/config.fish) ? Is it a symlink into the nix store ?

dawidd6 commented 3 weeks ago

Also, show us your PATH environment variable value.

victorhooi commented 3 weeks ago

@r-vdp Here's my fish config:

❯ cat ~/.config/fish/config.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 'cat\ \~/.config/fish/config.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 'cat\ \~/.config/fish/config.fish\ '
in event handler: handler for generic event “fish_preexec”
# ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated
# automatically by home-manager.

# Only execute this file once per shell.
set -q __fish_home_manager_config_sourced; and exit
set -g __fish_home_manager_config_sourced 1

source /nix/store/jwylbkjka0fspxkhic2vri072ic17mia-hm-session-vars.fish

status is-login; and begin

    # Login shell initialisation

end

status is-interactive; and begin

    # Abbreviations

    # Aliases

    # Interactive shell initialisation
    if test "$TERM" != dumb
        eval (/Users/foo/.nix-profile/bin/starship init fish)

    end

    # add completions generated by Home Manager to $fish_complete_path
    begin
        set -l joined (string join " " $fish_complete_path)
        set -l prev_joined (string replace --regex "[^\s]*generated_completions.*" "" $joined)
        set -l post_joined (string replace $prev_joined "" $joined)
        set -l prev (string split " " (string trim $prev_joined))
        set -l post (string split " " (string trim $post_joined))
        set fish_complete_path $prev "/Users/foo/.local/share/fish/home-manager_generated_completions" $post
    end

    /nix/store/y28f4m9ghwans8i6i7p31p1n7h9fl7dk-atuin-18.2.0/bin/atuin init fish | source

end

~/code/csv_playground is 📦 v0.1.0 via 🐍 v3.9.6 

And yes, from what I can see - the config file is a symlink:

❯ ls -lah ~/.config/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 'ls\ -lah\ \~/.config/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 'ls\ -lah\ \~/.config/fish/'
in event handler: handler for generic event “fish_preexec”
total 8
drwx------  7 foo  staff   224B Jun  3 12:40 ./
drwxr-xr-x  7 foo  staff   224B Jun  3 12:28 ../
drwxr-xr-x  2 foo  staff    64B May 28 13:42 completions/
drwxr-xr-x  2 foo  staff    64B May 28 13:42 conf.d/
lrwxr-xr-x  1 foo  staff    87B Jun  3 12:40 config.fish@ -> /nix/store/f2m99aq3y5xji83kn072dmdwn1pzr2p0-home-manager-files/.config/fish/config.fish
-rw-r--r--  1 foo  staff   1.3K May 28 13:42 fish_variables
drwxr-xr-x  2 foo  staff    64B May 28 13:42 functions/

@dawidd6 Here's my path under the Fish shell:

❯ 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:/usr/local/sbin:/opt/puppetlabs/bin

Here's my path if I spawn a bash shell:

bash-3.2$ env | grep PATH
PATH=/Users/foo/.local/share/bin:/Users/foo/.npm-packages/bin:/Users/foo/bin:/Users/foo/.pnpm-packages/bin:/Users/foo/.pnpm-packages:/Users/foo/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/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:/usr/local/sbin:/opt/puppetlabs/bin

and for zsh:

❯ env | grep PATH
PATH=/Users/foo/.local/share/bin:/Users/foo/.npm-packages/bin:/Users/foo/bin:/Users/foo/.pnpm-packages/bin:/Users/foo/.pnpm-packages:/Users/foo/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/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:/usr/local/sbin:/opt/puppetlabs/bin

It does seem slightly different - not sure why?