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

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,它会给你一个它认为不安全的目录列表 sudo chown -R username:root target_directory sudo chmod -R 755 target_directory

其他回答

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

Compaudit | xargs chmod g-w,o-w

在M1上工作过

ProductName:    macOS
ProductVersion: 11.1
BuildVersion:   20C69

% compaudit
/opt/homebrew/share

将组权限从775更改为755

% sudo chmod 755 /opt/homebrew/share

drwxr-xr-x   33 xenea  admin   1056 Feb  2 01:28 share

删除组写权限

compaudit | xargs chmod g-w

会成功的。

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

大多数答案都提供了解决方案,但没有提到为什么会出现这种警告。以下是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

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

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

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

解决方案是有用的

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

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