6/13/23

zsh compinit: insecure directories, run compaudit for list.

If you encountered this message prompt:
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]? 
And you googled, binged, chatgpt'ed and tried everthing, and you still got it.  This post is for you.

Do this, put this line in (create or append to) this file: .zshenv
skip_global_compinit=1
Save it and restart shell, the message should be gone.

If you on Mac, you can easily solve this by:
compaudit  # find out insecure directories
sudo chown -R yourname /usr/local/share/zsh
However, if you are in multi-user Linux environment, you may not be able to do it, and even you can do it, your message may be gone, other users will get that message.
The reason for this message is that zsh sources /etc/zsh/zshenv,  inside zshenv it run compinit.   zsh source /etc/zsh/zshrc before .zshrc, that's why even if you put `ZSH_DISABLE_COMPFIX=true`, or change other configs in zshrc, the message will still be there.
By putting `skip_global_compinit=1` in .zshenv, it will /etc/zsh/zshrc to not run compinit.  
If you use oh-my-zsh, you still need to put:
`ZSH_DISABLE_COMPFIX=true`
at the beginning of your .zshrc file, otherwise it gives you warnings other than that message prompt.

No comments: