國內安裝homebrew總結

用到的鏡像:
https://gitee.com/mirrors/homebrew.git
https://gitee.com/jinxin.70/homebrew-core.git
https://gitee.com/jinxin.70/homebrew-cask.git

1、安裝前準備:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.aliyun.com/homebrew/homebrew-core.git' >> ~/.bash_profile
source ~/.bash_profile

2、下載國內的安裝腳本:

git clone https://gitee.com/jinxin.70/install.git
cd install

我已經將腳本install.sh中的BREW_REPO變量改過了,有興趣你可以打開腳本看看

BREW_REPO="https://github.com/Homebrew/brew"

改成了

BREW_REPO="https://gitee.com/mirrors/homebrew.git"

3、接着,運行 install.sh 以安裝 Homebrew:

此時,你可能會卡在

==> Tapping homebrew/core

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'

ctrl+c停下,繼續下一步

4、手動克隆core和cask

cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://gitee.com/jinxin.70/homebrew-core.git
git clone https://gitee.com/jinxin.70/homebrew-cask.git

5、然後繼續運行安裝腳本install.sh

bash ~/install/install.sh

6、安裝好後,替換核心包倉庫的配置爲阿里雲鏡像

# 替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替換homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 應用生效
brew update

參考:
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
https://developer.aliyun.com/mirror/homebrew
https://juejin.cn/post/6844903782589923335

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章