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

3

7

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.

Remy answered 6/3, 2019 at 10:6 Comment(1)
Can you accept one of the answers, so the question doesn't stay open?Phoney
R
2

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.

Remy answered 9/3, 2019 at 14:52 Comment(0)
U
6

My Mac is on macOS Monterey v12.1.

I got this message after brew install zsh-completions and after many tries with stackoverflow answers, I solved this problem with source .zshrc and compaudit | xargs chmod g-w,o-w.

I hope your problem will be solved too

Urgent answered 4/1, 2022 at 16:54 Comment(0)
S
2

You should not install Homebrew with sudo. According to the Homebrew FAQ:

Homebrew is designed to work without using sudo. You can decide to use it but we strongly recommend not to do so. If you have used sudo and run into a bug then this is likely to be the cause. Please don’t file a bug report unless you can reproduce it after reinstalling Homebrew from scratch without using sudo.

The solution is to reinstall Homebrew without sudo but the user need to be administrator of the computer as you can see in the install script:

elsif !`dsmemberutil checkmembership -U "#{ENV["USER"]}" -G admin`.include?("user is a member")
  abort "This script requires the user #{ENV["USER"]} to be an Administrator."
Stocktonontees answered 9/3, 2019 at 7:48 Comment(4)
I didn't want to install it as admin, but when I installed it from my user account (by /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"), the installation script aborts with the message This script requires the user ronaldfischer to be an Administrator. So how can I then install it?Remy
Go tho the the System Preferences panel -> Users & Groups, click the lock to make changes then select the user and click on "Allow user to administer this computer"Stocktonontees
I know how to make my user account to have admin rights, but this is exactly I want to avoid: I normally do not want to have administrator privileges, for safety reason. Of course I could turn my user into admin, then install Homebrew, and then take away the admin privileges, but this seems to be a fairly odd solution to me. Would it then mean that for every other program which I install using brew or brew cask, I would have to play this game again - make me admin, do the installation, and take away admin rights afterwards?Remy
I just found this recipe for installing Homebrew with user privileges. Will give it a try.Remy
R
2

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.

Remy answered 9/3, 2019 at 14:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.