提示信息
打开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`。
根据提示我们可以作出如下的两种解决办法:
方法一:去掉相关文件夹的写权限
使用命令去掉相关文件夹的group
和others
分组的写权限:
$ 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