Search code examples
pathubuntu-16.04fish

Fish not accepting commands: set: Warning: $PATH entry is not valid


Something dumb happened. I tried to add something to the config.fish file to change the systemwide $PATH variable. I know, I probably should have read the documentation first, but I thought I know what I'm doing. Oh well.

To be more specific on what I did: I opened the config.fish file in /etc/fish and added the line export PATH=$PATH:/usr/local/gradle-4.5.1/bin to add gradle to my PATH-variable. Big mistake, because now my console won't accept anything anymore and I get the following whenever I open a console window: My question now: can I revert the change somehow without a console or is the only solution a reinstallation of my OS?

set: Warning: $PATH entry "/home/david/.local/bin" is not valid (Datei oder Verzeichnis nicht gefunden)
/usr/share/fish/functions/__fish_pwd.fish (Zeile 1): 
uname
^
Befehlsersetzungsblock
    called on line -1 of file /usr/share/fish/functions/__fish_pwd.fish

from sourcing file /usr/share/fish/functions/__fish_pwd.fish
    called on standard input

Befehlsersetzungsblock
    called on standard input

Befehlsersetzungsblock
    called on standard input

/usr/share/fish/functions/__fish_pwd.fish (Zeile 1): switch: Erwartete genau ein Argument, erhielt 0

switch (uname)
       ^
from sourcing file /usr/share/fish/functions/__fish_pwd.fish
    called on standard input

Befehlsersetzungsblock
    called on standard input

Befehlsersetzungsblock
    called on standard input

fish: 
echo $_ " "; __fish_pwd
             ^
Befehlsersetzungsblock
    called on standard input

~/.config/fish/functions/fish_greeting.fish (Zeile 1): 
set fish_greeting | figlet -f lean "Hi  David"
                    ^
Unbekannte Funktion 'fish_greeting'
    called on line 142 of file /usr/share/fish/functions/__fish_config_interactive.fish

Unbekannte Funktion '__fish_config_interactive'
    called on line 216 of file /usr/share/fish/config.fish

Unbekannte Funktion '__fish_on_interactive'
    called on standard input

in event handler: handler for generic event 'fish_prompt'

Befehl »tty« ist unter »/usr/bin/tty« verfügbar
Der Befehl konnte nicht gefunden werden, weil »/usr/bin« nicht Teil der Umgebungsvariable PATH ist.
tty: Befehl nicht gefunden.
~/.config/fish/functions/fish_prompt.fish (Zeile 3): 
    tty | string match -q -r tty
    ^
Unbekannte Funktion 'fish_prompt'
    called on standard input

Befehlsersetzungsblock
    called on standard input

Befehl »hostname« ist unter »/bin/hostname« verfügbar
Der Befehl konnte nicht gefunden werden, weil »/bin« nicht Teil der Umgebungsvariable PATH ist.
hostname: Befehl nicht gefunden.
/usr/share/fish/functions/prompt_hostname.fish (Zeile 1): 
hostname | string split '.'
^
Befehlsersetzungsblock
    called on line -1 of file /usr/share/fish/functions/prompt_hostname.fish

from sourcing file /usr/share/fish/functions/prompt_hostname.fish
    called on line 2 of file ~/.config/fish/functions/fish_prompt.fish

Befehlsersetzungsblock
    called on line 0 of file ~/.config/fish/functions/fish_prompt.fish

Befehlsersetzungsblock
    called on line 0 of file ~/.config/fish/functions/fish_prompt.fish

Unbekannte Funktion 'fish_prompt'
    called on standard input

Befehlsersetzungsblock
    called on standard input

Befehl »sed« ist unter »/bin/sed« verfügbar
Der Befehl konnte nicht gefunden werden, weil »/bin« nicht Teil der Umgebungsvariable PATH ist.
sed: Befehl nicht gefunden.
~/.config/fish/functions/fish_prompt.fish (Zeile 1): 
pwd|sed "s=$HOME=~="
    ^
Befehlsersetzungsblock
    called on line 0 of file ~/.config/fish/functions/fish_prompt.fish

Unbekannte Funktion 'fish_prompt'
    called on standard input

Befehlsersetzungsblock
    called on standard input

Befehl »date« ist unter »/bin/date« verfügbar
Der Befehl konnte nicht gefunden werden, weil »/bin« nicht Teil der Umgebungsvariable PATH ist.
date: Befehl nicht gefunden.
~/.config/fish/functions/fish_prompt.fish (Zeile 1): 
date +%X
^
Befehlsersetzungsblock
    called on line 0 of file ~/.config/fish/functions/fish_prompt.fish

Unbekannte Funktion 'fish_prompt'
    called on standard input

Befehlsersetzungsblock
    called on standard input

__fish_pwd: Befehl nicht gefunden.
fish: 
echo $_ " "; __fish_pwd
             ^
Befehlsersetzungsblock
    called on standard input

Solution

  • can I revert the change somehow without a console or is the only solution a reinstallation of my OS?

    A reinstall is complete overkill.

    Fish should still accept commands, it's just that there are so many commands in your prompt and such that it's hard to see the output.

    Thankfully $PATH on many Linux distributions is quite simple, with most applications in /usr/bin. So set -gx PATH /usr/bin should get you to a state where you can edit config.fish to remove your mistake.

    Or you could use absolute paths in the fish command, e.g. /usr/bin/sudo /usr/bin/nano /etc/fish/config.fish should open nano with your config.fish.

    Or you can open your config.fish in a graphical text editor that has the capability to edit root-owned files (e.g. Kate just asks for your password once you try to save)

    Or you can change the "shell" or "profile" setting in your terminal - they don't need to open your users configured shell, they can also usually open an arbitrary program, like a different shell.