問題
運(yùn)行命令時(shí)镐躲,[oh-my-zsh] 冒出下面一大堆提示:
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxr-xr-x 16 duke staff 512 Jul 14 10:14 /Users/duke/.oh-my-zsh
drwxr-xr-x 250 duke staff 8000 Jul 14 10:14 /Users/duke/.oh-my-zsh/plugins
drwxr-xr-x 4 duke staff 128 Jul 14 10:14 /Users/duke/.oh-my-zsh/plugins/git
drwxr-xr-x 3 duke staff 96 Jun 17 11:33 /usr/local/share/zsh
drwxr-xr-x 6 duke staff 192 Oct 3 10:04 /usr/local/share/zsh/site-functions
lrwxr-xr-x 1 duke staff 39 Jun 17 11:37 /usr/local/share/zsh/site-functions/_brew -> ../../../Homebrew/completions/zsh/_brew
lrwxr-xr-x 1 duke staff 44 Jun 17 11:37 /usr/local/share/zsh/site-functions/_brew_cask -> ../../../Homebrew/completions/zsh/_brew_cask
lrwxr-xr-x 1 duke staff 58 Oct 3 10:04 /usr/local/share/zsh/site-functions/_git -> ../../../Cellar/git/2.19.0_2/share/zsh/site-functions/_git
[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.
解決
問題的描述中给涕,其實(shí)已經(jīng)給了我們解決方法:
[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.
要修復(fù)權(quán)限穗椅,可以通過禁用“group”和“others”的寫入權(quán)限并確保這些目錄的所有者是root用戶或當(dāng)前用戶來修復(fù)權(quán)限吁恍。
以下命令可能有所幫助:
compaudit | xargs chmod g-w胰舆,o-w
如果上面沒有幫助册舞,或者你想跳過不安全目錄的驗(yàn)證蕴掏,你可以在你的zshrc文件中找到oh-my-zsh之前將變量ZSH_DISABLE_COMPFIX設(shè)置為“true”。
第一種解決方法:修改相關(guān)文件夾權(quán)限
為以上提示的文件夾修改權(quán)限(根據(jù)具體提示修改)
chmod 755 /Users/duke/.oh-my-zsh
chmod 755 /Users/duke/.oh-my-zsh/plugins
chmod 755 /Users/duke/.oh-my-zsh/plugins/git
chmod 755 /usr/local/share/zsh/site-functions
chmod 755 /usr/local/share/zsh/site-functions/_brew
chmod 755 /usr/local/share/zsh/site-functions/_brew_cask
chmod 755 /usr/local/share/zsh/site-functions/_git
第二種解決方法:設(shè)置變量 ZSH_DISABLE_COMPFIX=true
- 在.zshrc文件的第一行添加
ZSH_DISABLE_COMPFIX=true
- 運(yùn)行source命令调鲸,重新加載.zshrc文件
source ~/.zshrc