How to Fix the 'zsh compinit: insecure directories' Error on macOS
Step-by-step guide to resolving the 'zsh compinit: insecure directories' error after installing Homebrew on macOS.

If you’ve recently installed the Homebrew package manager on macOS, you might encounter an error message in your Terminal similar to this:
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
compinit: initialization aborted
This error can be frustrating, but don’t worry—this guide will walk you through the steps to resolve it. We’ll cover what causes the error and how to fix it quickly.
Understanding the Error
The error message relates to “insecure directories” and often appears when using the zsh shell after installing Homebrew.
Since macOS Catalina (version 10.15), zsh has been the default login shell. If you used earlier versions of macOS, you may not have seen this issue because bash was the default shell.
Identifying the Insecure Directories
To find out which directories are causing the problem, use the compaudit command:
$ compaudit
There are insecure directories:
/usr/local/share
In this example, /usr/local/share is flagged as insecure.
Resolving the Issue
To fix the zsh compinit: insecure directories error, follow these steps:
-
Open Terminal.
-
Run the following command:
compaudit | xargs chmod g-w
Here’s what this command does:
compauditlists the insecure directories.xargspasses each directory tochmod g-w.chmod g-wremoves group write permissions, making the directories secure.
After running this command, check again with compaudit:
$ compaudit
# No insecure directories (empty output)
You should no longer see the error.
Conclusion
Thanks for reading! I hope this guide helps you resolve the error on your macOS system.
See you next time!
