[oh-my-zsh] 提示 Insecure completion-dependent directories detected解决办法

[oh-my-zsh] 提示 Insecure completion-dependent directories detected解决办法
Mac上安装完oh-my-zsh后,命令行终端提示:[oh-my-zsh] Insecure completion-dependent directories detected: drwxrwxr-x ...

提示信息

打开Mac Terminal命令行窗口时,[oh-my-zsh] 提示一堆警告信息:

Last login: Tue Mar 24 13:45:50 on ttys000
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x  3 tzq  admin   96  3 22 23:18 /usr/local/share/zsh
drwxrwxr-x  4 tzq  admin  128  3 22 23:28 /usr/local/share/zsh/site-functions

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

解决方法

提示信息中已经给了我们解决方法:

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

大概意思就是说解决这个问题,可以通过去掉给出目录的“group”和“others”分组的写权限并确保其所有者是root或当前用户。
参考命令:
compaudit | xargs chmod g-w, o-w
如果使用参考命令没有效果,或者只想跳过不安全目录的验证,可以在~/.zshrc文件中设置变量ZSH_DISABLE_COMPFIX的值为true`。

根据提示我们可以作出如下的两种解决办法:

方法一:去掉相关文件夹的写权限

使用命令去掉相关文件夹的groupothers分组的写权限:

$ chmod g-w, o-w /usr/local/share/zsh
$ chmod g-w, o-w /usr/local/share/zsh/site-functions
或者
$ chmod 755 /usr/local/share/zsh
$ chmod 755 /usr/local/share/zsh/site-functions

方法二:设置变量ZSH_DISABLE_COMPFIX = true

~/.zshrc文件中添加ZSH_DISABLE_COMPFIX = true配置,并运行source命令,重新加载.zshrc文件

$ vi ~/.zshrc
ZSH_DISABLE_COMPFIX = true

修改完后使用source命令,重新加载.zshrc文件

$ source ~/.zshrc

the end

标签: Mac ZSH
热门文章