闻心阁

一蓑烟雨看苍生,半壶浊酒笑红尘

解决 Oh My Zsh Insecure Completion Dependent Directories Detected

2021-04-03 约 1 分钟读完 搬砖秘籍

今天把Mac重新安装了一下,之前Windows系统被我干掉了,没有别的原因。用Mac装Windows这事儿,如果只是偶尔用用倒是还好,如果想长期使用,还是建议专门找个Windows的电脑。使用MacBook装的话比较伤电池,并且触摸板之类的体验也远不如原生的MacOS。

废话不多说,今天重装的时候,还是安装了Oh My Zsh,但出现了如下报错。

Insecure completion-dependent directories detected:
drwxrwxr-x  3 xxx  admin   96 Mar 27 16:50 /usr/local/share/zsh
drwxrwxr-x  4 xxx  admin  128 Apr  3 19:16 /usr/local/share/zsh/site-functions

[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 directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

解决方案一

执行如下命令:

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

解决方案二

在你的.zshrc文件中添加如下的代码。

ZSH_DISABLE_COMPFIX=true

然后执行

source .zshrc

问题解决。