mac osx brew 使用清華源靠譜的


github官方源連不上

 

 

科大源,阿里雲源都太慢,阿里雲還容易出錯

 

用清華源好

 

成功安裝brew后,輸入如下命令:

1、官網brew.sh復制安裝腳本。

2、自動安裝完成后,更換為清華源來加快速度。網址為:https://mirrors.tuna.tsinghua.edu.cn/help/homebrew

3、更換homebrew

cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git brew update

更換homebrew-bottles (長期換源)

 

查看當前Homebrew 鏡像源

# brew.git鏡像源
git -C "$(brew --repo)" remote -v

# homebrew-core.git鏡像源
git -C "$(brew --repo homebrew/core)" remote -v

# homebrew-cask.git鏡像源
git -C "$(brew --repo homebrew/cask)" remote -v 

國內鏡像地址

科大真香實例:

git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

if [ $SHELL = "/bin/bash" ] # 如果你的是bash
then 
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.bash_profile
    source ~/.bash_profile
elif [ $SHELL = "/bin/zsh" ] # 如果用的shell 是zsh 的話
then
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.zshrc
    source ~/.zshrc
fi

brew update

如果需要恢復原有鏡像源的話(國內鏡像源突然不能用了或版本不夠新)

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.git

# 找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行刪除

brew update

如果可以了下面的就不用看了

如果不行的話可以依次嘗試以下命令

brew doctor
brew update-reset
brew update
推薦閱讀: 有趣的 Homebrew 命名

 

 

 
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile


免責聲明!

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



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