macOS軟件包管理器
官網(wǎng)
安裝
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
卸載
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
常用命令
brew help 查看幫助
brew install <package name> 安裝軟件包
brew uninstall <package name> 卸載軟件包
brew list [--versions] 列出已安裝的軟件包(包括版本)
brew search <package name> 查找軟件包
brew info <package name> 查看軟件包信息
brew update 更新brew
brew outdated 列出過(guò)時(shí)的軟件包(已安裝但不是最新版本)
brew upgrade [<package name>] 更新過(guò)時(shí)的軟件包(不指定軟件包表示更新全部)
brew doctor 檢查brew運(yùn)行狀態(tài)
常見(jiàn)問(wèn)題
更換更新源
替換brew.git:
$ cd "$(brew --repo)"
中國(guó)科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
清華大學(xué):
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
替換homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
中國(guó)科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
清華大學(xué):
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
替換homebrew-bottles:
中國(guó)科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
清華大學(xué):
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
應(yīng)用生效:
$ brew update
中國(guó)科大開(kāi)源軟件鏡像站
清華大學(xué)開(kāi)源軟件鏡像站
重置設(shè)置
診斷Homebrew的問(wèn)題:
$ brew doctor
重置brew.git設(shè)置:
$ cd "$(brew --repo)"
$ git fetch
$ git reset --hard origin/master
homebrew-core.git同理:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git fetch
$ git reset --hard origin/master
應(yīng)用生效:
$ brew update
重置更新源
重置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-bottles:
刪除/usr/.bash_profile環(huán)境變量HOMEBREW_BOTTLE_DOMAIN
應(yīng)用生效:
$ brew update