你可能嘗試了很多辦法去安裝brew,從一開始的網絡超時,到一臉蒙的手動安裝,本文教你如何正確安裝brew
創建Homebrew目錄
打開你的終端執行下面的命令,進行創建Homebrew
sudo mkdir /usr/local/Homebrew
同步brew.git庫
sudo git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git /usr/local/Homebrew
添加環境變量
sudo ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
同步core庫
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
sudo git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
同步cask
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
sudo git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
提權
sudo chown -R $(whoami) /usr/local/Cellar
查看版本號
brew -v

更換鏡像源
此時你安裝東西的話,還是會感受到超時的力量,所以我們需要更換國內鏡像源
替換homebrew默認源
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
bash用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile #刷新
zsh用戶
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc #刷新
記得要更新
brew update
我的博客即將同步至騰訊雲+社區,邀請大家一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=2t77vjr03n288
