Search code examples
shellterminalfish

Fish-shell throws error on startup. Wrong number of arguments


I have been using fish-shell on a mac for a few months with no issues. All of a sudden, when I open the terminal I get the following error message:

/usr/local/share/fish/functions/__fish_pwd.fish (line 1): 
uname
^
in command substitution
    called on line 1 of file /usr/local/share/fish/functions/__fish_pwd.fish

from sourcing file /usr/local/share/fish/functions/__fish_pwd.fish
    called on line 2 of file /usr/local/share/fish/functions/fish_title.fish

in command substitution
    called on line 2 of file /usr/local/share/fish/functions/fish_title.fish

in command substitution
    called on line 3 of file /usr/local/share/fish/functions/fish_title.fish

in function 'fish_title'
    called on standard input

in command substitution
    called on standard input

/usr/local/share/fish/functions/__fish_pwd.fish (line 1): switch: Expected exactly one argument, got 0

switch (uname)
       ^
from sourcing file /usr/local/share/fish/functions/__fish_pwd.fish
    called on line 2 of file /usr/local/share/fish/functions/fish_title.fish

in command substitution
    called on line 2 of file /usr/local/share/fish/functions/fish_title.fish

in command substitution
    called on line 3 of file /usr/local/share/fish/functions/fish_title.fish

in function 'fish_title'
    called on standard input

in command substitution
    called on standard input

/usr/local/share/fish/functions/fish_title.fish (line 1): 
__fish_pwd
^
in command substitution
    called on line 3 of file /usr/local/share/fish/functions/fish_title.fish

in function 'fish_title'
    called on standard input

in command substitution
    called on standard input

I see there is an issue with the number of arguments. However, it appears that there is 1 argument even though it says there is 0. Here are the contents of the __fish_pwd.fish file:

switch (uname)
    case 'CYGWIN_*'
        function __fish_pwd --description "Show current path"
            pwd | sed -e 's-^/cygdrive/\(.\)/\?-\u\1:/-'
        end
    case '*'
        function __fish_pwd --description "Show current path"
            pwd
        end
end

Here are the contents of config.fish when it wasn't working. Removing the last line export PATH=$M3:$PATH solved the problem.

# put ~/.local/bin/ in my path
set PATH ~/.local/bin $PATH

# spark
set SPARK_HOME /usr/local/Cellar/apache-spark/2.4.4
set PATH $SPARK_HOME/bin:$PATH
set -x PYSPARK_PYTHON python3.7

# sbt: build tool for scala and java
export M3_HOME=/usr/local/etc/sbtopts
export M3=$M3_HOME/bin
export PATH=$M3:$PATH

Solution

  • However, it appears that there is 1 argument even though it says there is 0.

    Well, not really.

    The 1 argument it wants is after expansion. In this case it runs uname, and uses its output as the argument to switch.

    You appear to have changed something about your system so that uname doesn't print anything anymore - perhaps you added a function called uname, or you changed $PATH so that uname isn't included anymore.