Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh path "no such file or directory" where do I unset it?

Tags:

zsh

zshrc

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:

  1. /etc/zshenv
  2. ~/.zshenv
  3. /etc/zprofile
  4. ~/.zprofile
  5. /etc/zshrc
  6. ~/.zshrc
  7. ~/.zpreztorc
  8. /etc/zlogin
  9. ~/.zlogin
  10. ~/.zlogout
  11. /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!

like image 524
superuseroi Avatar asked Feb 06 '14 16:02

superuseroi


People also ask

How do you deal with no such file or directory?

The error "FileNotFoundError: [Errno 2] No such file or directory" is telling you that there is no file of that name in the working directory. So, try using the exact, or absolute path. In the above code, all of the information needed to locate the file is contained in the path string - absolute path.

Why I am getting no such file or directory?

log No such file or directory” the problem is most likely on the client side. In most cases, this simply indicates that the file or folder specified was a top-level item selected in the backup schedule and it did not exist at the time the backup ran.

What is path in Zshrc?

PATH is an environment variable where you tell your system to look for executables when you enter a command in the shell. You can inspect the value of the PATH variable by running the following.

Where is zsh profile stored?

The zsh shell provides the . zprofile under the user home directory in order to load profile related configuration. The path is ~/. zprofile and can be used like a bash profile file with zsh commands.


1 Answers

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
like image 54
Adaephon Avatar answered Sep 18 '22 17:09

Adaephon