zsh path "no such file or directory" where do I unset it?
As far as I can tell there is nothing wrong with your PATH
. If you want to see the content of PATH
use echo
:
% echo $PATH
/usr/sbin:/usr/bin:/sbin:/bin
PATH
is a colon separated list of directories to search for commands. Essentially, zsh will try the name of your command with each path and execute the first find (/usr/sbin/foo
, /usr/bin/foo
, etc.). If any of the listed directories does not exist, there will be no error message, zsh will simply not find a binary there and try the next one.
The issue in your case is triggered by trying to execute $PATH
. Before executing a command line, zsh - among other things - replaces all variables with their content, this is called Parameter Expansion (so man 1 zshexpn
for more information on that).
So, when you just write $PATH
, zsh replaces it with /usr/bin:/bin:/usr/sbin:/sbin:...
and interpretes it as one long path. That is, :
is not taken as separator but as part of the directory names. Any you are getting the same error message you would get with any other non-existent directory:
% ls /some/path
dir1 dir2
% /some/path/nothere/notthere
zsh: no such file or directory: /some/path/nothere/notthere
superuseroi
Updated on July 21, 2022Comments
-
superuseroi almost 2 years
I just noticed that my
$PATH
has an invalid location:\> $PATH
zsh: no such file or directory: /usr/bin:/bin:/usr/sbin:/sbin: ...I use prezto and according to the docs the config files are sourced in this order:
- /etc/zshenv
- ~/.zshenv
- /etc/zprofile
- ~/.zprofile
- /etc/zshrc
- ~/.zshrc
- ~/.zpreztorc
- /etc/zlogin
- ~/.zlogin
- ~/.zlogout
- /etc/zlogout
I checked the whole list and I can't find anything that would come before
/usr/bin
Any suggestion on how I could go about finding what is triggering the issue?
Thanks!