Following a post on SO, this can only be circumvented by calling chmod 755 and chown root:staff on the directories in question.
No offense, but SO offers wrong answers or bad suggestions very often, even when said answers have hundreds of upvotes from equally confused users. (I say this as someone who was once active in the bash and zsh tags, and later left due to the low quality of questions.) In this case
chmod -R 755 on
/usr/local/share/zsh/site-functions is both ridiculously wrong and useless (unless the guy somehow screwed up permissions with e.g.
chmod -R 777 in the first place; even then zsh functions shouldn’t be executable).
What you should do instead is read the manual http://zsh.sourceforge.net/Doc/Release/Completion-System.html, which is very clear on this issue:
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.
As you can see, world- or group-writability isn’t a problem here unless you have messed with it. The problem is
/usr/local/share/zsh/site-functions and files in it needs to be owned by your standard user or root to pass the security check. Since both would be a pain to use with Homebrew, you’re left with the option
compinit -u. This is generally not recommended, but if you’re the only one that’s ever going to touch your computer, or the admin account, it should be fine. (But don’t hold me accountable if you’re ever hacked.)
However, it should be possible to use the software it installs as every other standard user, no?
The problem is the discrepancy between Homebrew’s trust model and zsh’s (or that of most standard Unix software). Homebrew reserves root for only a handful of things that are absolutely necessary (as it recognizes the danger of installing arbitrary software as root), and uses the admin account for things that are somewhat risky; standard Unix software only trusts root, and assumes that sudoers who install stuff as root has audited every piece of software (which in practice is of course untrue).
P.S. Those who recommend chmod/chown with the -R flag for whatever reason without a YUGE warning flag should be held accountable. It’s on the same level as
rm -rf /.