最近學(xué)習(xí)flutter 著手安裝開發(fā)環(huán)境
安裝homebrew的時候 各種報錯都遇到了一遍
因為眾所周知的原因 官方的代碼倉庫訪問不穩(wěn)定導(dǎo)致
后面嘗試了碼云上的一鍵安裝的腳本 也一樣報錯
最終在查看了各種文檔之后整理出一套快速安裝的方法
分享一下 為大家避坑 環(huán)境為英特爾芯片的mac os
1.在安裝之前設(shè)置環(huán)境變量
#設(shè)置環(huán)境變量 設(shè)置中科大源
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
#檢查環(huán)境變量是否設(shè)置成功
env
2.用jsdelivr CDN的安裝文件安裝Homebrew
#從jsdelivr CDN加速下載安裝腳本安裝Homebrew(訪問github失敗時使用)
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"
#github上的官方安裝文件(如果訪問正??梢允褂茫?/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/HEAD/install.sh)"
3.安裝Homebrew cask
#mac用戶安裝Homebrew cask軟件倉庫
brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.ustc.edu.cn/homebrew-cask.git
4.安裝Homebrew cask(根據(jù)需求決定是否安裝)
#安裝Homebrew cask其他版本軟件倉庫,提供使用人數(shù)多的、需要的版本不在 cask 倉庫中的應(yīng)用。(根據(jù)需求決定是否安裝)
brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.ustc.edu.cn/homebrew-cask-versions.git
5.更新homebrew并檢查配置
#應(yīng)用brew配置
brew update-reset
#更新homebrew
brew update
#查看homebrew配置
brew config
6.永久替換中科大源
#查看shell模式
echo $SHELL
# bash 用戶
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bash_profile
# zsh 用戶
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zshrc
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zshrc
#bash用戶檢查永久配置是否成功
cat ~/.bash_profile
#zsh用戶檢查永久配置是否成功
cat ~/.zshrc
卸載homebrew
#從碼云下載腳本卸載
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/uninstall.sh)"
#從碼云下載腳本卸載(僅限mac os)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
*一鍵安裝homebrew(替換了中科大源)
#作者修改了中科大源 沒有安全風(fēng)險(如介意請使用上面的安裝步驟)
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
Homebrwe常用命令分享
#安裝軟件(將xxx替換為軟件名)
brew install xxx
#卸載軟件
brew uninstall xxx
#搜索軟件
brew search xxx
#更新軟件
brew upgrade xxx
#查看已安裝列表
brew list
#更新brew
brew update
#清理所有包的舊版本
brew cleanup
#清理指定包的舊版本
brew cleanup $FORMULA
#查看可清理的舊版本包,不執(zhí)行實際操作
brew cleanup -n