brew update 更新时报错

3 篇文章 0 订阅
2 篇文章 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 -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就可以了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值