这意味着什么?我该如何解决?

zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

运行compaudit将返回如下结果:

There are insecure directories:
/usr/local/share/zsh/site-functions

当前回答

我的建议是运行compaudit,然后修复由审计发现的目录的权限。 确保识别的目录没有组或其他的写权限。

其他回答

我在运行google-cloud-sdk安装脚本后得到了这个问题,该脚本通过.zshrc中的一个条目将命令补全添加到shell中。

按照Homebrew的说明在zsh中配置补全是有帮助的。

此外,如果你在尝试加载这些补全时收到" zsh compinit: insecure directories "警告,你可能需要运行这个:chmod -R go-w "$(brew——prefix)/share"

删除组写权限

compaudit | xargs chmod g-w

会成功的。

参见http://www.wezm.net/technical/2008/09/zsh-cygwin-and-insecure-directories/

发送一个y字符到脚本的输入流使用compinit,以自动回答忽略不安全的目录和文件,并继续[y]或abort compinit [n]?问题

echo "y" > source <GOOGLECLOUDSDK>/ complete .zsh.inc .

解决方案是有用的

不能对文件夹进行所有权/访问更改 当你不能使用-u选项来删除警告时(可能是因为你自己没有显式地调用'compinit',但它是由你调用的脚本调用的)

备注:它不会修复问题,只是隐藏了警告(与这里涉及删除“组写访问权限”或“更改所有权到根”的其他答案相反)。

接受的答案在macOs Sierra(10.12.1)上不适用。必须从/usr/local递归吗

cd /usr/local
sudo chown -R <your-username>:<your-group-name> *

注意:你可以用whoami获取你的用户名,用id -g获取你的组

我尝试了张贴的每一个解决方案,最后没有一个适合我的特殊情况。然而,我想向那些向我指出所有权是多账户真正问题的用户表示感谢,而不是模式。 我把这个答案发布给其他有类似设置的人(M1 +两个账户+ /opt/homebrew/share)。

下面是我的设置:

我有一台M1,运行macOS Monterey 12.0.1,使用Homebrew。

我有两个帐户,一个管理员和一个普通用户(需要分开工作)。 我只有在普通用户上有不安全的目录问题,两个用户使用相同的自制设置,以下目录和文件受到问题的影响:

/opt/homebrew/completions/zsh/_brew
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/share/zsh/site-functions/_brew_services
/opt/homebrew/share/zsh/site-functions/_cargo
/opt/homebrew/share/zsh/site-functions/_gh
/opt/homebrew/share/zsh/site-functions/_git
/opt/homebrew/share/zsh/site-functions/_j
/opt/homebrew/share/zsh/site-functions/_lf
/opt/homebrew/share/zsh/site-functions/_task
/opt/homebrew/share/zsh/site-functions/_tldr
/opt/homebrew/share/zsh/site-functions/_vifm

改变模式没有任何作用,最终解决问题的方法是将每个问题文件和目录的所有权更改为root:admin,如下所示:

sudo chown root:admin /opt/homebrew/share/zsh/site-functions/*

最初,在问题出现之前,我的管理员用户拥有所有的东西,因此所有权看起来像这样:usr:admin

这是站点功能目录现在的样子,没有问题:

lrwxr-xr-x  1 root admin  30 Jul 19 19:41 _brew ->../../../completions/zsh/_brew
lrwxr-xr-x  1 root admin  79 Aug 10 20:26 _brew_services -> ../../../Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services
lrwxr-xr-x  1 root admin  59 Nov  6 16:28 _cargo -> ../../../Cellar/rust/1.56.1/share/zsh/site-functions/_cargo
lrwxr-xr-x  1 root admin  53 Dec  2 23:37 _gh -> ../../../Cellar/gh/2.3.0/share/zsh/site-functions/_gh
lrwxr-xr-x  1 root admin  56 Nov 30 15:21 _git -> ../../../Cellar/git/2.34.1/share/zsh/site-functions/_git
lrwxr-xr-x  1 root admin  61 Oct 13 11:12 _j -> ../../../Cellar/autojump/22.5.3_3/share/zsh/site-functions/_j
lrwxr-xr-x  1 root admin  50 Oct 23 18:52 _lf -> ../../../Cellar/lf/26/share/zsh/site-functions/_lf
lrwxr-xr-x  1 root admin  57 Nov  6 16:28 _task -> ../../../Cellar/task/2.6.1/share/zsh/site-functions/_task
lrwxr-xr-x  1 root admin  57 Nov 18 01:45 _tldr -> ../../../Cellar/tldr/1.4.2/share/zsh/site-functions/_tldr
lrwxr-xr-x  1 root admin  56 Oct 13 11:11 _vifm -> ../../../Cellar/vifm/0.12/share/zsh/site-functions/_vifm