解决MacOS的brew updating缓慢

元气小坏坏 提交于 2020-02-27 03:51:13

分析更新缓慢的原因

使用brew update --verbose观察update过程,查看阻塞点:

$ brew update -v
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
remote: Counting objects: 686, done.
remote: Compressing objects: 100% (285/285), done.
remote: Total 686 (delta 509), reused 566 (delta 392)
Receiving objects: 100% (686/686), 143.36 KiB | 0 bytes/s, done.
Resolving deltas: 100% (509/509), completed with 83 local objects.
From https://mirrors.ustc.edu.cn/brew
   bcb8f4d..5e17527  master     -> origin/master
 * [new tag]         2.2.3      -> 2.2.3
 * [new tag]         2.2.4      -> 2.2.4
 * [new tag]         2.2.5      -> 2.2.5
From https://mirrors.aliyun.com/homebrew/homebrew-core
   dd2fae0..f8547f7  master     -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
Updating /usr/local/Homebrew...
Branch master set up to track remote branch master from origin.
Switched to and reset branch 'master'
Your branch is up-to-date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

如果是阻塞在brew源的访问上,则可以更换国内的brew源的服务器地址,更新方法如下

更换brew镜像源

# 进入brew主目录
$ cd `brew --repo`
# 更换镜像
$ git remote set-url origin https://git.coding.net/homebrew/homebrew.git
# 测试效果
$ brew update

几个镜像:

  • https://git.coding.net/homebrew/homebrew.git - Coding
  • https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git - 清华
  • https://mirrors.ustc.edu.cn/brew.git - 中科大

参考

https://xu3352.github.io/mac/2018/09/06/mac-homebrew-update-slowly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!