首先这是homebrew的官网
https://brew.sh/index_zh-cn
安装方法是在终端中输入
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
需要说明的是最好提前在终端中将curl的postBuffer的默认值提高
不然,可能会报如下的错误信息
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
对此的解决方法时
在终端中输入
git config --global http.postBuffer 1048576000 # 这里的数字是字节数 # 这里给的是 1000MB 也就是1000 * 1024 * 1024 # 可以根据自己的需求更改数值 # 修改完毕后 可以通过以下命令查看postBuffer git config --list
还可能出现以下错误 即提示网速不够 请求被停止了
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
可以通过以下方法解决:
方法一:更换下载源到国内的清华源
step1:更换仓库源
cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git brew update
step2:更换 Homebrew-bottles 镜像(影响软件下载速度)
临时修改
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
永久修改
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/