No such file or directory .zshrc
17,547
zsh
is working as expected (see man zshbuiltins
):
. File
searches$PATH
to findFile
unless there is a/
in the name; whilesource
is almost the same as.
, except that it searches the working directory first.
I don't know how . .zshrc
worked previously, unless there was a bug in an earlier release of zsh
.
You can:
alias .=source
;- link
~/.zshrc
to a directory in$PATH
; - add your home directory to
$PATH
(not recommended); or - live with having to type
. ./.zshrc
(this is what I always do inbash
, where.
andsource
are identical, and I want to be sure of the location of the script).
Related videos on Youtube
Author by
Prashanth Chandra
Computer Science student and ME[AR]N stack + Unix enthusiast. I also play around with Android, Java and Python.
Updated on September 18, 2022Comments
-
Prashanth Chandra over 1 year
Recently, I realized I haven't been able to run
. .zshrc
in my home directory. It gives me the error above. It's really strange and it's bugging me out since it's worked perfectly fine in the past.
In the same directory, any of the below commands work fine
. ~/.zshrc source .zshrc
Output from
echo $PATH | tr ':' '\n'
/Users/prashanthcr/.rvm/gems/ruby-2.2.0/bin /Users/prashanthcr/.rvm/gems/ruby-2.2.0@global/bin /Users/prashanthcr/.rvm/rubies/ruby-2.2.0/bin /Users/prashanthcr/.nvm/versions/node/v5.5.0/bin /Users/prashanthcr/Library/Android/sdk/platform-tools /Users/prashanthcr/Library/Android/sdk/tools /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/X11/bin /usr/local/MacGPG2/bin /Users/prashanthcr/.rvm/gems/ruby-2.2.0/bin /Users/prashanthcr/.rvm/gems/ruby-2.2.0@global/bin /Users/prashanthcr/.rvm/bin
Using zsh on OS X 11.11.3
-
Prashanth Chandra over 8 yearsThanks for the man reference. I guess I may have mixed it up with bash, which apparently does look in the current directory when POSIX mode is turned off (which seems to be the normal setting).
-
AFH over 8 yearsThanks for the comment on
bash
: I hadn't realised.
andsource
check the current directory, but after finding no match in$path
, whereassource
inzsh
checks it first. I missed it because I tested with two files of the same name, one in the current directory, the other in$path
.