美文网首页
brew update 更新时报错

brew update 更新时报错

作者: 辉色星空下 | 来源:发表于2023-03-22 15:28 被阅读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
    remote: Enumerating objects: 365476, done.
    remote: Counting objects: 100% (365455/365455), done.
    remote: Compressing objects: 100% (147319/147319), done.
    fatal: The remote end hung up unexpectedly12 MiB | 9.00 KiB/s     
    fatal: early EOF
    fatal: index-pack failed
    

    但试了几次都没有成功,报错如下

    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
    remote: Enumerating objects: 365476, done.
    remote: Counting objects: 100% (365455/365455), done.
    remote: Compressing objects: 100% (147319/147319), done.
    fatal: The remote end hung up unexpectedly12 MiB | 9.00 KiB/s     
    fatal: early EOF
    fatal: index-pack failed
    

    需要换到国内的镜像,执行如下命令:

    ## 更新 homebrew-cask(如果提示 No such file or directory 可以先跳过前三个命令)
    cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
     
    # 更换源
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
     
    # 更新
    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 
    

    常用的国内镜像有(上面的不行就多试几个):

    https://mirrors.ustc.edu.cn/homebrew-core.git
    https://mirrors.aliyun.com/homebrew/homebrew-core.git
    https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
    

    再执行brew update就可以了。

    相关文章

      网友评论

          本文标题:brew update 更新时报错

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