安裝brew的正確姿勢
- 2020 年 4 月 9 日
- 筆記
你可能嘗試了很多辦法去安裝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
部落格內容遵循 署名-非商業性使用-相同方式共享 4.0 國際 (CC BY-NC-SA 4.0) 協議 本文永久鏈接是:https://mrhuanhao.cn/2020/03/31/installbrew/ 轉載時,請註明文章來源!!!