After switching my shell from bash to zsh with the macOS Catalina update, Homebrew and zsh are fighting over how they need /usr/local/share/zsh/site-functions and /usr/local/share/zsh to be owned.
zsh prefers that /usr/local/share/zsh/**/* be owned by root, and otherwise raises the annoying error
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]?
every time I log in as root, for example via sudo -s.
I ran compaudit as root then chown root'd and chmod g-w'd all the directories that it listed. That satisfied zsh but now homebrew isn't happy.
Any brew install or upgrade fails with
Error: The following directories are not writable by your user:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions
And make sure that your user has write permission.
chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions
brew doctor gives the same message as a warning.
Is there a compromise between the two? Or one of these warnings I can safely suppress? If so, how?