What does it mean and how can I fix it?
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compini
Most answers come with a solution, but do not mention why this warning occurs. Here's an excerpt from ZSH's compinit:
For security reasons compinit also checks if the completion system would use files not owned by root or by the current user, or files in directories that are world- or group-writable or that are not owned by root or by the current user. If such files or directories are found, compinit will ask if the completion system should really be used. To avoid these tests and make all files found be used without asking, use the option -u, and to make compinit silently ignore all insecure files and directories use the option -i. This security check is skipped entirely when the -C option is given.
Hence, the solution implies fixing one (or all) of the following:
setting the current user as the owner of all the directories/subdirectories/files in cause:
compaudit | xargs chown -R "$(whoami)"
removing write permissions for group/others for the files in cause:
compaudit | xargs chmod go-w
Another approach would be to skip these checks by using
compinit -u
but I don't really suggest this, as hiding problems under a rug only solves problems in the short run.