解决 Homebrew 安装、更新很慢的方法

有的时候我们使用 Homebrew 安装或者更新库的时候,速度很慢,可能还会出现“Error: Failed to download resource “gettext””等情况,主要原因是 Homebrew 的源在国外。解决办法有两个,要么大清早,网络不卡的时候来更新,当然部分的源可能大清早也没用,另外一种方法就是更换成国内的源。

解决 Homebrew 安装、更新慢的方法。

今天就给大家介绍一下如何更换成国内的源,使用的是清华大学的源,下面的代码一行一行运行。

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

使用国内的源的时候,使用 brew doctor 命令检查 Homebrew 问题的时候会有一个警告,我们当然也可以把源改回去原来的,代码也一行一行去运行:

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core
brew update

扩展阅读:

清华大学的 Homebrew 帮助文档

Homebrew 的常见用法

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>