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

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

当前回答

这个答案主要是我自己在未来使用的参考,因为大多数答案都没有提供一个成熟的解决方案。下面就是:

第一次运行:

compinit

如果以上都不起作用,请使用compaudit

对于打印的每个路径,运行以下命令:

sudo chown $(whoami) PATH_HERE

sudo chmod -R 755 PATH_HERE

简单的例子,假设运行compinit后打印的路径之一是“/usr/local/share/zsh”。然后:

sudo chown $(whoami) /usr/local/share/zsh

sudo chmod -R 755 /usr/local/share/zsh

其他回答

我得到这个问题在过去的5个月尝试了一些事情,但没有工作。最后帮助我的是这个。获取不安全目录的列表,然后按照下面的描述设置所有这些目录的chmod。

CLI# compaudit
There are insecure directories:
/usr/local/share/zsh
CLI# sudo chmod -R 755 /usr/local/share/zsh
Password:

运行compaudit,它会给你一个它认为不安全的目录列表 sudo chown -R username:root target_directory sudo chmod -R 755 target_directory

大多数答案都提供了解决方案,但没有提到为什么会出现这种警告。以下是ZSH公司的一段摘录:

For security reasons compinit also checks if the completion system would use files not owned by root or by the current user, or files in directories that are world- or group-writable or that are not owned by root or by the current user. If such files or directories are found, compinit will ask if the completion system should really be used. To avoid these tests and make all files found be used without asking, use the option -u, and to make compinit silently ignore all insecure files and directories use the option -i. This security check is skipped entirely when the -C option is given.

因此,解决方案意味着解决以下一个(或所有)问题:

将当前用户设置为所有目录/子目录/文件的所有者,原因如下: compaudit | xargs chown -R "$(whoami)" 删除组/others文件的写权限,原因如下: Compaudit | xargs chmod go-w

另一种方法是使用跳过这些检查

compinit -u

但我并不建议这样做,因为把问题藏在地毯下只能在短期内解决问题。

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

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

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

在我的mac OS Catalina上运行这个命令是有效的:

Compaudit | xargs chmod g-w,o-w