Zsh detects insecure completion-dependent directories

MacosZshOh My-ZshHyperterminal

Macos Problem Overview


I get the following error messages when I open my terminal, Hyper:

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x  7 dwaynethe2nd  admin  224 Apr 25 15:00 /usr/local/share/zsh
drwxrwxr-x  4 dwaynethe2nd  admin  128 Apr 25 14:53 /usr/local/share/zsh/site-functions

Macos Solutions


Solution 1 - Macos

This is an issue with ZSH, your shell, not Hyper, your terminal. I actually had the same issue earlier today. There are some solutions in this issue on Github, and I will quote some of them here but I recommend you follow the link and read the comments there.

The first solution is to change the ownership of the problematic directories.

I will not recommend this without knowing more about your environment, but for most people this will fix the issue:

chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions

The second solution is to set ZSH_DISABLE_COMPFIX=true (or "true" in quotes) in your .zshrc file, to tell ZSH to not check for insecure directories.

The third solution, and the solution that fixed the issue for me, is to initialise compinit with the -u flag. This will use all the directories found by compaudit without checking them for security issues. To do this, you will have to change your .zshrc file or wherever you are configuring autocomplete.

Solution 2 - Macos

On my mac, what helped was running brew doctor

The program told me the exact commands to run!

Solution 3 - Macos

Reinstalling brew solved this problem for me.

Uninstall brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

Install brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Solution 4 - Macos

Executing two commands solved my issue.

  1. sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions
  2. chmod u+w /usr/local/share/zsh/usr/local/share/zsh/site-functions

Solution 5 - Macos

For me, the site-functions were symlinked to Homebrew directories.

/usr/local/share/zsh/site-functions/_brew -> ../../../Homebrew/completions/zsh/_brew

So the only thing that would work is to issue the command against those directories directly.

sudo chown -R $USER /opt/homebrew/completions/zsh/_brew 

Or for cellars

sudo chown -R $USER /opt/homebrew/Cellar/ripgrep/13.0.0/share/zsh/site-functions/_rg

I'm not sure whether this will pop up again when running brew update.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMetalFingersView Question on Stackoverflow
Solution 1 - MacosrunarView Answer on Stackoverflow
Solution 2 - MacosazizbroView Answer on Stackoverflow
Solution 3 - MacosTapas PalView Answer on Stackoverflow
Solution 4 - MacoschetyView Answer on Stackoverflow
Solution 5 - MacosWhat Would Be CoolView Answer on Stackoverflow