Search code examples
macosterminalzsh

zsh compinit: insecure directories, run compaudit for list


I get this when I tre to run the terminal on my mac:

zsh compinit: insecure directories, run compaudit for list. Ignore insecure directories and continue [y] or abort compinit [n]? y

Suggested answers like this are of no use to me as they all involve running commands which I'm not currently able to do. How do I resolve this?

Ths is my .zshrc:

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="$HOME/.jenv/bin:$PATH:/Users/paulcarron/Apache/apache-maven-3.8.1/bin"
eval "$(jenv init -)"
export NVM_DIR=~/.nvm
    source $(brew --prefix nvm)/nvm.sh
source ~/.bash_profile

.bashrc:

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
eval "$(jenv init -)"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
if [ -r ~/.zshrc ]; then
   source ~/.zshrc
fi

Solution

  • You have a created an infinite loop in your dotfiles. Your .zshrc sources your .bashrc, which sources your .zshrc, ad infinitum.

    Additionally, when you source "$NVM_DIR/bash_completion" from zsh, it for some strange reason calls compinit. (This is something that nvm should not do.)

    So, there you have it: Together, you’ve created yourself infinite compinits.

    Moral of the story: It’s already a bad idea to source .bashrc from .zshrc, or vice versa, but doing it in both directions is even worse.

    Solution: Don’t do that and remove the offending lines from your dotfiles.