原 brew
源极慢,有必要把 Homebrew
源改为成国内源。
Homebrew 源主要有四个部分组成:
名称 |
说明 |
brew |
Homebrew 源代码仓库 |
homebrew-core |
Homebrew 核心软件仓库 |
homebrew-bottles |
Homebrew 预编译二进制软件包 |
homebrew-cask |
提供 macOS 应用和大型二进制文件 |
安装 brew
如果还没安装 homebrew,则需要先安装。
用官网推荐安装方式:
1
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
如果安装很慢,可使用清华源安装
1 2 3
| git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install /bin/bash brew-install/install.sh rm -rf brew-install
|
查看当前源
1 2 3 4 5 6 7 8 9
| $ cd "$(brew --repo)" && git remote -v origin https://github.com/Homebrew/brew.git (fetch) origin https://github.com/Homebrew/brew.git (push)
$ cd "$(brew --repo homebrew/core)" && git remote -v origin https://github.com/Homebrew/homebrew-core.git (fetch) origin https://github.com/Homebrew/homebrew-core.git (push)
|
改为阿里源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile echo 'export HOMEBREW_API_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles/api' >> ~/.bash_profile
source ~/.bash_profile
$ brew update
$ brew cleanup
|
你也可以试用清华源
1 2 3 4
| 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 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile echo 'export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api' >> ~/.bash_profile
|
改回官方源
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| $ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask
$ vim ~/.bash_profile
|
参考:《Mac 下 brew 切换为国内源》