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

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

当前回答

我的机器:

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

点击这里阅读更多链接

其他回答

更新所有权限正确的文件/文件夹:

Compaudit | xargs chmod g-w

您不需要使用sudo更改所有者-除非文件属于root

(在macOS BigSur上测试)

在macOS Sierra上,你需要运行: sudo chown -R $(whoami):staff /usr/local

这是我在https://github.com/zsh-users/zsh-completions/issues/433#issuecomment-600582607上唯一有用的东西。感谢https://github.com/malaquiasdev !

  $ cd /usr/local/share/
  $ sudo chmod -R 755 zsh
  $ sudo chown -R root:staff zsh

我的机器:

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

点击这里阅读更多链接

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

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