一、在mac上安装brew,执行以下命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果出现以下错误:
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
网络问题导致异常,ping不同git,可以修改安装配置,下载配置文件:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
更换数据镜像:
vim brew_install
将git源进行修改
BREW_REPO = "https://github.com/Homebrew/brew".freeze
更改为
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
重新执行安装脚本
/usr/bin/ruby brew_install
安装完成后,替换homebrew源,执行如下命令
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
使用brew update确认更新到最新版本后,设置 bintray镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
二、进行brew update出现:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
错误的原因是项目时间太长,Tag资源文件过大,执行:
git config --global http.postBuffer 524288000
三、brew相关命令:
命令 描述
brew install 安装Homebrew
brew update 更新 Homebrew
brew uninstall 卸载Homebrew
brew doctor 修复Homebrew
brew upgrade 更新所有安装过的软件包
brew upgrade xxx 更新指定的软件包
brew search xxx 查找软件包
brew install xxx 安装软件包
brew remove xxx 卸载软件包
brew list 列出已安装的软件包
brew info xxx 查看软件包信息
brew deps xxx 列出软件包的依赖关系
brew outdated 列出可以更新的软件包