打开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.

这是由于 /usr/local/share/zsh /usr/local/share/zsh/site-functions 这两个目录权限不对,给这个两个目录更改下权限就可以了。

  1. chmod 755 /usr/local/share/zsh
  2. chmod 755 /usr/local/share/zsh/site-functions

大概意思就是说解决这个问题,可以通过去掉给出目录的“group”和“others”分组的写权限并确保其所有者是root或当前用户。
参考命令:

  1. compaudit | xargs chmod g-w, o-w

如果使用参考命令没有效果,或者只想跳过不安全目录的验证,可以在~/.zshrc文件中设置变量ZSH_DISABLE_COMPFIX的值为true`。

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

方法一:去掉相关文件夹的写权限
使用命令去掉相关文件夹的group和others分组的写权限:

  1. $ chmod g-w, o-w /usr/local/share/zsh
  2. $ chmod g-w, o-w /usr/local/share/zsh/site-functions

或者

  1. $ chmod 755 /usr/local/share/zsh
  2. $ chmod 755 /usr/local/share/zsh/site-functions

方法二:设置变量ZSH_DISABLE_COMPFIX = true
在~/.zshrc文件中添加ZSH_DISABLE_COMPFIX = true配置,并运行source命令,重新加载.zshrc文件

  1. $ vi ~/.zshrc
  2. ZSH_DISABLE_COMPFIX = true

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

  1. $ source ~/.zshrc

分类: web

标签: