314 字
2 分钟
Homebrew的安装
2020-06-17

安装#

由于某些原因,官方提供的安装方法会非常慢,因此从Github直接下载源码包,然后再把下载地址替换为国内镜像。

替换安装地址#

install.sh用记事本打开,并把其中的BREW_REPO=的地址改为:

BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

这里用的是清华大学的镜像。

替换其他地址#

上面仅仅替换了第一步的下载地址,Homebrew还会自动下载brew-core、brew-bottle、brew-cask等内容,而这些内容的下载地址在源文件中本人没有找到,因此要在terminal下载这些内容时,按control+c来中断程序,并手动指定下载地址。

Homebrew-core#

若卡在:

==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

或这里下载很慢时,按control+c来中断程序,并输入如下代码:

cd "$(brew --repo)/Library/Taps/"
mkdir homebrew && cd homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git

Homebrew-cask#

在安装cask卡住时,方法同上:

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

安装成功#

之后继续安装,出现==> Installation successful!表明安装成功。

更改源地址#

需要替换brew、brew-core、brew-cask、brew-bottle的地址,以防平时使用时下载速度过慢。

清华大学源#

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
brew update
Homebrew的安装
https://blog.xiaobaizhang.top/posts/homebrewinstall/
作者
张小白
发布于
2020-06-17
许可协议
CC BY-NC-SA 4.0