HomeBrew-修改镜像源解决慢的问题

16次阅读

共计 972 个字符,预计需要花费 3 分钟才能阅读完成。

今天发现在用 brew 安装一个软件的时候非常非常慢,半天没反应,怀疑因为软件源在外国受墙的影响。
于是看了一下当前使用的是哪个源:

# 进入 brew 的仓库根目录
TMBP:~ tony$ cd "$(brew --repo)"

# 查看仓库地址
TMBP:Homebrew tony$ git remote -v
origin    https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (fetch)
origin    https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (push)

可以看到,其实 brew 的仓库本质上就是一个 git 仓库。

打开 https://mirrors.tuna.tsinghua… 地址一看,发现不见了 …

原来不是墙的干扰(一般情况下 GitHub 不会被墙,顶多也就慢一点)。

回到清华大学开源软件镜像站首页搜了一下,发现地址没错,确实是 https://mirrors.tuna.tsinghua…

这就有点尴尬了,清华坑人啦~

于是网上找了个中科大的源 https://mirrors.ustc.edu.cn/b…

看起来不错~

改成中科大的源:

# 进入 brew 的仓库根目录
cd "$(brew --repo)"

# 修改为中科大的源
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

同理,修改 homebrew-cask、homebrew-core、homebrew-services 的远程仓库地址

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

修改完仓库地址后,更新一下,加上 -v 参数可以看到当前跑的进度:

brew update -v


改完之后,果然快的一米!

正文完
 0