这意味着什么?我该如何解决?
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
这意味着什么?我该如何解决?
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
当前回答
我没有看到任何关于这个主题的自制信息的回答: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之前完成。
这为我解决了问题,无需手动更改所有权或其他方式。
其他回答
当我sudo -i启动根shell时,我得到了相同的警告,@chakrit的解决方案对我不起作用。
但我发现-u开关的compinit工作,例如在你的.zshrc/zshenv或你调用compinit的地方
compinit -u
注意:不建议用于生产系统
参见http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Initialization
我在运行google-cloud-sdk安装脚本后得到了这个问题,该脚本通过.zshrc中的一个条目将命令补全添加到shell中。
按照Homebrew的说明在zsh中配置补全是有帮助的。
此外,如果你在尝试加载这些补全时收到" zsh compinit: insecure directories "警告,你可能需要运行这个:chmod -R go-w "$(brew——prefix)/share"
在莫哈韦沙漠,这招奏效了: Sudo chmod go-w /usr/local/share
(2022年更新)
如果使用ZSH补全,你应该使用chmod -R go-w "$(brew——prefix)/share"
我尝试了张贴的每一个解决方案,最后没有一个适合我的特殊情况。然而,我想向那些向我指出所有权是多账户真正问题的用户表示感谢,而不是模式。 我把这个答案发布给其他有类似设置的人(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
我的机器:
System Version: macOS 10.15.4 (19E287)
Kernel Version: Darwin 19.4.0
这就是我所做的,
运行compaudit,它会给你一个它认为不安全的目录列表。 执行sudo chmod -R 755 target_directory命令 (例如:sudo chmod -R 755 /usr/local/share/zsh)
例子:
compaudit
返回:
/usr/local/share/zsh
所以我跑了
sudo chmod -R 755 /usr/local/share/zsh
点击这里阅读更多链接