macOS High Sierra10.13.3安装homebrew报错LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54解决方法

 

在mac系统中,使用homebrew能够很方便的管理包。按照官网的说明执行如下命令时老是报错: html

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

应该是这个资源访问有问题,那么咱们能够尝试使用国内的镜像。给你们推荐一个中国科学技术大学的镜像站点,里面有各类资源: https://mirrors.ustc.edu.cn/brew.git git

言归正传,开始踩坑github

第一步,获取install文件

把官网的brew_install安装脚本经过如下命令下载下来 shell

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

第二步,更改脚本中的资源连接,替换成中国科学技术大学的镜像

就是把这两句 ruby

BREW_REPO = "https://github.com/Homebrew/brew".freeze
CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

更改成这两句 bash

BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git".freeze

固然若是这个镜像有问题的话,能够换成别的,注意:新版本的brew_install脚本文件中取消了CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze这句,能够不用替换。-更新日期20200225app

第三步,执行脚本

/usr/bin/ruby brew_install

而后可能卡在了Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...,能够看到这几句: curl

==> Tapping homebrew/coreurl

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...spa

fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

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

出现这个缘由是由于源不通,代码来不下来,解决方法就是更换国内镜像源:

执行下面这句命令,更换为中国科学技术大学的镜像:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

就下载成功了

而后把homebrew-core的镜像地址也设为中国科学技术大学的国内镜像,按顺序在终端执行下面命令

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

最后用这个命令检查无错误:

brew doctor

这样海外和已经有系统全局代理设置的朋友们就能够直接使用 brew 命令安装软件了。

第四步、接着换源

直接使用 Homebrew 还须要更改默认源,否则谁用谁想打人,缘由你懂的。如下是将默认源替换为国内 USTC 源的方法。

替换核心软件仓库

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

若是你没有安装Homebrew-Cask不用执行下面这句命令替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)

cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

zsh 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

 

Homebrew基本用法:

假定操做对象为 wget,请替换为本身须要的软件包名

操做 命令
更新 Homebrew brew update
更新全部安装过的软件包 brew upgrade
更新指定的软件包 brew upgrade wget
查找软件包 brew search wget
安装软件包 brew install wget
卸载软件包 brew remove wget
列出已安装的软件包 brew list
查看软件包信息 brew info wget
列出软件包的依赖关系 brew deps wget
列出能够更新的软件包 brew outdated

参考资料:

Homebrew 中文主页

https://brew.sh/index_zh-cn.html

 Homebrew Bottles 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-bottles.html

 Homebrew Cask 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-cask.git.html

 Homebrew Core 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-core.git.html