Search code examples
homebrewzshmacos-sierrahomebrew-cask

zsh compinit: insecure directories error message on Mac, after installing Homebrew


After installing Homebrew and Homebrew-Cask on my Mac (as administrator with user-id 'admin', running MacOS 10.12.6), I get the error message

zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

every time I start zsh. Investing the issue with compaudit, I found mentioned several insecure directories, most related to Homebrew - for example /usr/local/share/zsh/site-functions. This directory and its entries have access rights 0755, which should be OK, but - for example - the entry

/usr/local/share/zsh/site-functions/_brew

which is a symlink to a file in Homebrew which defines the completions for zsh, has the owner admin. My guess is that zsh wants to see the user root here.

If this were Linux, I would simply change the owner of these files to root, or rather, I would have made the whole installation as root in the first place. In MacOS 10.12 however, they even "administrators" are not allowed to take full control over the system and while I can login as administrator, I don't even know the password of root.

Is there a clever solution to this problem? Or, can we teach zsh compinit somehow to never ask this annoying question and either accept the insecure directories, or skip over them? Or would it be best to login as admin, and simply delete the offending symlinks from site-functions? I can live with a completion system, which does not know how to handle brew commands.


Solution

  • I found, that the error message was generated by a call to compinit in my .zshrc, and that it can be turned off by passing the -i option, i.e.

     compinit -i
    

    While this solves the problem, the argument brought by Ortomala Lokni that Homebrew should be installed using user privilege, is also worth considering - only that Homebrew does not allow me to do this; but this is a topic for a separate thread.