Fixing compinit: insecure directories and files
After installing nvm on my Macbook I kept getting the error
zsh compinit: insecure directories and files whenever I opened a new shell. The script would prompt for me continue or abort.
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]?
My initial Google searches found results suggesting that I change file ownership or permissions but this either didn't work or caused other issues. After being driven crazy by this for months I finally solved the problem.
The error was being caused when the
$NVM_DIR/bash_completion script was being run in my
.zshrc file. That script runs the
It turns out that the
compinit command can be run with a
-u option which makes it silently ignore these error. Clearly this is a known problem because the call to
compinit is wrapped in a check allowing it to be called with or without the
In the end all I needed to do is add one line to my
~/.zshrc file before the line running
$NVM_DIR/bash_completion now runs
compinit -u which ignores the errors.