引子
安装HomeBrew,Mac用的少,记录下,以免忘记
安装
方式1. 简单的脚本安装brew [网络正常访问raw.githubusercontent.com]
1
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
方式2. ruby shell [网络正常访问raw.githubusercontent.com]
1
| /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
由于网络资源的原因,国内使用上面的方式很慢,经常失败,解决办法以下两种
方式3. 替换镜像源
方式4. 使用全局代理(挂VPN)
错误处理
1. 如果出现错误
1 2 3 4 5 6 7 8 9
| Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
Error: Failure while executing: /usr/local/bin/brew tap homebrew/core
Failed during: /usr/local/bin/brew update --force
|
可以手动下载国内仓库
安装brew:
1 2
| mkdir -p /usr/local/Homebrew/Library/Taps/homebrew git clone git://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
|
安装brew cask:
1
| git clone git://mirrors.ustc.edu.cn/homebrew-cask.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1
|
2. 如果出现错误 raw.githubusercontent.com 无法访问
可以去网站 https://www.ipaddress.com/ 查询raw.githubusercontent.com 地址
如下图所示
修改hosts, 添加
1
| 199.232.68.133 raw.githubusercontent.com
|
替换brew镜像源
1 2 3 4 5 6
| 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 cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
|
卸载brew
ruby
1
| ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
|
shell
1
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
|