sudo -s 命令 [oh-my-zsh] 報錯


運行sudo -s 命令時,[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.

  

解決方案如下:

問題的描述中,其實已經給了我們解決方法:

[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文件中找到oh-my-zsh之前將變量ZSH_DISABLE_COMPFIX設置為“true”。

 

第一種:修改相關文件夾權限

為以上提示的文件夾修改權限(根據具體提示修改)
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

第二種:設置變量 ZSH_DISABLE_COMPFIX=true

  1. 在.zshrc文件的第一行添加 ZSH_DISABLE_COMPFIX=true
  2. 運行source ~/.zshrc,重新加載.zshrc文件

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM