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

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

当前回答

当我sudo -i启动根shell时,我得到了相同的警告,@chakrit的解决方案对我不起作用。

但我发现-u开关的compinit工作,例如在你的.zshrc/zshenv或你调用compinit的地方

compinit -u

注意:不建议用于生产系统

参见http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Initialization

其他回答

删除组写权限

compaudit | xargs chmod g-w

会成功的。

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

当我sudo -i启动根shell时,我得到了相同的警告,@chakrit的解决方案对我不起作用。

但我发现-u开关的compinit工作,例如在你的.zshrc/zshenv或你调用compinit的地方

compinit -u

注意:不建议用于生产系统

参见http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Initialization

在莫哈韦沙漠,这招奏效了: Sudo chmod go-w /usr/local/share

(2022年更新)

如果使用ZSH补全,你应该使用chmod -R go-w "$(brew——prefix)/share"

我没有看到任何关于这个主题的自制信息的回答:https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh

要使Homebrew的完成功能在zsh中可用,必须在初始化zsh的完成功能之前在FPATH上获得Homebrew管理的zsh site-functions。将以下内容添加到~/。zshrc中:

if type brew &>/dev/null; then
  FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH

  autoload -Uz compinit
  compinit
fi

这必须在调用compinit之前完成。

这为我解决了问题,无需手动更改所有权或其他方式。

这适用于我的Mac,因为High Sierra更新。

取消组写权限:

sudo chmod g-w /usr/local/share/zsh/site-functions
sudo chmod g-w /usr/local/share/zsh

最好将更改限制在zsh目录中。