“zsh compinit: insecure files” Prompt on oh-my-zsh

Problem

Get a prompt every time you launch the terminal with oh-my-zsh installed:

[oh-my-zsh] Insecure completion-dependent directories detected:
lrwxr-xr-x 1 root staff 39 10 Sep 2021 /usr/local/share/zsh/site-functions/_brew -> ../../../Homebrew/completions/zsh/_brew
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w
[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
zsh compinit: insecure files, run compaudit for list.
Ignore insecure files and continue [y] or abort compinit [n]?

Solution

Instead of the regular steps mostly you can get from a Google search:

$ sudo chmod -R 755 /usr/local/share/zsh/site-functions$ sudo chown -R root:root /usr/local/share/zsh/site-functions

And as the prompt suggested, add the ZSH_DISABLE_COMPFIX=true in your ~/.zshrc.

Nothing worked for me until the line below saved my day!

sudo chown root /usr/local/share/zsh/site-functions/_brew

It was suggested at the beginning of the prompt which I always overlooked. 🤦‍♂

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store