zsh - 如何解决zsh compinit : insecure directories issue on MacOS (other solutions failed)

标签 zsh oh-my-zsh

我知道这里有很多这个问题的副本,但他们的所有答案都建议添加

ZSH_DISABLE_COMPFIX="true"
到我的 ~/.zshrc 文件的顶部。我已经这样做了,但每次打开 zsh 时,我都会受到欢迎
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
似乎其他问这个问题的人在第一个样本中没有引用真实的引号,但我已经添加了。我也跑了
源 ~/.zshrc
据我所知,这会重新加载 zshrc 配置。这仍然给了我上述警告。我不确定这些细节中的任何一个是否相关,但我会包括它们:
  • 这是在运行 Big Sur 的 M1 Macbook 上安装的新 zsh
  • 我还在 zsh 之上安装了 Oh My Zsh
  • 我早些时候运行了几个导出命令来设置我的 nvm 目录,但我认为这无关紧要

  • 知道如何解决此权限问题吗?谢谢
    编辑:
    comaudit 返回
    /usr/local/share/zsh/site-functions
    /usr/local/share/zsh
    
    此外,这是我的 ~/.zshrc 文件中的其他非标准条目(按顺序排列,但中间有一些内置内容):
    ZSH_DISABLE_COMPFIX="true"
    export NVM_DIR=~/.nvm
    source $(brew --prefix nvm)/nvm.sh
    export PATH="/usr/local/opt/icu4c/bin:$PATH"
    export PATH="/usr/local/opt/icu4c/sbin:$PATH"
    export PATH=$HOME/bin:/usr/local/bin:$PATH
    plugins=(git)
    source $ZSH/oh-my-zsh.sh
    zstyle :compinstall filename '/Users/jonahsaltzman/.zshrc'
    # End of lines configured by zsh-newuser-install
    # The following lines were added by compinstall
    autoload -Uz compinit
    compinit
    

    最佳答案

    首先,这里的一个问题是您运行 compinit两次:一次通过 Oh-My-Zsh(当你做 source $ZSH/oh-my-zsh.sh 时)和一次手动。您有两个选项可以解决此问题:

  • 如果您想继续使用 Oh-My-Zsh,那么您应该从 .zshrc 中删除底部 3 行文件。
  • 如果你想停止使用 Oh-My-Zsh,那么你应该同时删除 plugins=(git)source $ZSH/oh-my-zsh.sh .

  • 其次,请注意 $ZSH_DISABLE_COMPFIX特定于 Oh-My-Zsh,compinit 不使用本身。拨打compinit无效手动。您可以从 .zshrc 中删除它.
    最后,compinit不会无故显示该警告。与其压制它,不如做 chmod g-w,o-wcompaudit 列出的目录中.这将解决问题并使警告消失。

    关于zsh - 如何解决zsh compinit : insecure directories issue on MacOS (other solutions failed),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65484115/

    相关文章:

    linux - 如何更改 zsh-autosuggestions 颜色

    shell - zsh 在执行搜索和补全时插入额外的空格

    zsh - 为什么此代码在传递给 `zsh -n` 而不是传递给 `zsh` 时抛出错误?

    git - 终端 Git 跟踪与 VS Code git 跟踪不同步

    macos - 在 OSX 上安装 Typesafe 激活器

    oh-my-zsh - 如何修复 "oh-my-zsh plugin ' docker ,' not found"

    oh-my-zsh - iTerm2/哦我的 Zsh : How to change preview text font color?

    visual-studio-code - 从 Ubuntu WSL2 运行 VSCode 不起作用

    linux - zsh compinit : insecure directories. Compaudit 显示/tmp 目录

    configuration - 在 z shell 中向前移动一个单词