Homebrew 使用國內鏡像


在國內的網絡環境下使用 Homebrew 安裝軟件的過程中,可能會長時間卡在 Updating Homebrew ...

方法一:按command + c 取消本次更新操作,直接安裝軟件

方法二:設置國內鏡像

1.替換 brew.git 倉庫地址


# 阿里巴巴的 brew.git 倉庫地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 中國科學技術大學的 brew.git 倉庫地址
cd "$(brew --repo)" 
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

2.替換 homebrew-core.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

# 替換中國科學技術大學的 homebrew-core.git 倉庫地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" 
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

3.替換 homebrew-cask.git 倉庫地址

# 中國科學技術大學的 homebrew-cask 倉庫地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

4.替換 homebrew-bottles 訪問地址

# 替換阿里巴巴的 homebrew-bottles 訪問 URL:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile

# 替換中國科學技術大學的 homebrew-bottles 訪問 URL:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile

還原:

# 還原爲官方提供的 brew.git 倉庫地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

# 還原爲官方提供的 homebrew-core.git 倉庫地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

# 還原爲官方提供的 homebrew-cask.git 倉庫地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://github.com/Homebrew/homebrew-cask.git

# 還原爲官方提供的 homebrew-bottles 訪問地址
vi ~/.bash_profile
# 然後,刪除 HOMEBREW_BOTTLE_DOMAIN 這一行配置
source ~/.bash_profile

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