macOS软件包管理器
官网
安装
/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 列出过时的软件包(已安装但不是最新版本)
brew upgrade [<package name>] 更新过时的软件包(不指定软件包表示更新全部)
brew doctor 检查brew运行状态
常见问题
更换更新源
替换brew.git:
$ cd "$(brew --repo)"
中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
清华大学:
$ 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"
中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
替换homebrew-bottles:
中国科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
清华大学:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
应用生效:
$ brew update
重置设置
诊断Homebrew的问题:
$ brew doctor
重置brew.git设置:
$ 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
应用生效:
$ 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环境变量HOMEBREW_BOTTLE_DOMAIN
应用生效:
$ brew update