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

 


轉自:https://blog.csdn.net/iroguel/article/details/93481795


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM