Zsh detects insecure completion-dependent directories
Asked Answered
P

8

73

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
Protectionism answered 25/4, 2020 at 22:3 Comment(0)
E
154

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.

Expatriate answered 25/4, 2020 at 22:19 Comment(7)
I used the command the error message recommended to remove the write permissions for group and others. I think it's just asking to lock it down more, but it's not a clear error message. compaudit | xargs chmod g-w,o-wNitrogen
@SalahAdDin: Have you tried all three solutions? Do you see any error messages or any other information you would like to share? For the record, it worked for me and I'm using macOS Catalina myself.Expatriate
I disabled that zsh feature.Kingwood
Hey I know this is an old-ish post but after running the chmod 755..., ZSH takes an absolute age to load up after opening the terminal...any idea what this might be?Jeffery
Hi guys, I have two accounts in the macOS. So, we shouldn't use the first solution. And the second solution does not make sense we all know. The third solution, I always get the permission issue with my standard user(the folder own of admin account)Somniloquy
Hi, this might be coming late but can someone explain what this warning error exactly means? OMZ seems to have added the above solutions as reference for fixing this error but I want to understand what exactly am I solving here. Thanks!Downstream
@AshishGupta It means you do not have the appropriate file permissions for these directories. Another solution is chown $USER /usr/local/share/zsh.Excide
S
18

On my mac, what helped was running brew doctor

The program told me the exact commands to run!

Sugared answered 19/11, 2021 at 3:18 Comment(1)
This is definitely the simplest answer, worked wondersEberto
T
5

What solved it for me (on OSX) was to change the ownership on all the directories that are called out after you see [Insecure completion-dependent directories detected:].

Important: You have to change permissions on the target files if they are symlinked. For me the complete list was:

sudo chown -R $(whoami) /usr/local/share/zsh 
sudo chown -R $(whoami) /usr/local/share/zsh/site-functions
sudo chown -R $(whoami) /usr/local/Homebrew/completions/zsh/_brew
sudo chown -R $(whoami) /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services
sudo chown -R $(whoami) /usr/local/Cellar/gh/2.4.0/share/zsh/site-functions/_gh
sudo chown -R $(whoami) /usr/local/Cellar/tldr/1.4.2/share/zsh/site-functions/_tldr
Technique answered 5/8, 2022 at 15:35 Comment(0)
O
3

In my case following works.

sudo chown -R $(whoami) /usr/local/share/zsh 
sudo chown -R $(whoami) /usr/local/share/zsh/site-functions
sudo chown -R $(whoami) /usr/local/Homebrew/completions/zsh/_brew
sudo chown -R $(whoami) /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services
Offertory answered 22/10, 2022 at 11:59 Comment(0)
M
1

To fix this, I used the ZSH_DISABLE_COMPFIX option. The key to using this one is that it has to be placed before/above the “source $ZSH/oh-my-zsh.sh” line:

# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

#Fix errors
ZSH_DISABLE_COMPFIX="true"

source $ZSH/oh-my-zsh.sh

# User configuration
Maximin answered 2/12, 2022 at 14:31 Comment(0)
R
0

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)"
Rounder answered 20/9, 2021 at 19:19 Comment(1)
Just so as not to confuse anyone: if you've never installed or heard of Homebrew, this solution and the one just above are not your problem.Nickeliferous
G
0

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
Guadalupe answered 14/2, 2022 at 9:38 Comment(0)
E
0

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.

Edmonson answered 7/5, 2022 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.