美文网首页
brew update 报错:This restriction

brew update 报错:This restriction

作者: 1166f7d8293b | 来源:发表于2021-06-27 10:59 被阅读0次

    问题:

    Mac 下执行 brew update 时,报如下错误:

    Error:
      homebrew-core is a shallow clone.
      homebrew-cask is a shallow clone.
    To `brew update`, first run:
      git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
      git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
    These commands may take a few minutes to run due to the large size of the repositories.
    This restriction has been made on GitHub's request because updating shallow
    clones is an extremely expensive operation due to the tree layout and traffic of
    Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
    automatically to avoid repeatedly performing an expensive unshallow operation in
    CI systems (which should instead be fixed to not use shallow clones). Sorry for
    the inconvenience!
    

    如果只需按上述提示执行相应命令即可:

      git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
      git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
    

    但是 git 仓库是国外的,速度慢,还经常被墙,导致 early EOF 之类的错误。

    更换数据源:

    ## 更新 homebrew-cask
    cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
    
    ## 更换源
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
    
    ## 更新,由于已经 cd 到相应文件夹了,因此不需要通过 -C 指定路径了
    git fetch --unshallow 
    
    ## 更新 homebrew-core
    cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-core
    
    ## 更换源
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    ## 更新
    git fetch --unshallow 
    

    如果还不能更新,执行如下命令查看远端 repo 是不是设置错了。

    git remote -v 
    

    最后执行 brew update 即可。

    相关文章

      网友评论

          本文标题:brew update 报错:This restriction

          本文链接:https://www.haomeiwen.com/subject/gebyyltx.html