No such file or directory .zshrc

17,547

zsh is working as expected (see man zshbuiltins):

  • . File searches $PATH to find File unless there is a / in the name; while
  • source 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:

  1. alias .=source;
  2. link ~/.zshrc to a directory in $PATH;
  3. add your home directory to $PATH (not recommended); or
  4. live with having to type . ./.zshrc (this is what I always do in bash, where . and source are identical, and I want to be sure of the location of the script).
Share:
17,547

Related videos on Youtube

Prashanth Chandra
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, 2022

Comments

  • Prashanth Chandra
    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
    Prashanth Chandra over 8 years
    Thanks 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
    AFH over 8 years
    Thanks for the comment on bash: I hadn't realised . and source check the current directory, but after finding no match in $path, whereas source in zsh 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.