天天看點

macOS Catalina 10.15.1安裝homebrew報錯 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

1、更新homebrew

$ brew update
           

報錯:

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

解決方案:

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

進入到brew_install

按 i 進入編輯模式

更改腳本中的資源連結,替換成中國科學技術大學的鏡像
	就是把這兩句 
	BREW_REPO = “https://github.com/Homebrew/brew“.freeze 
	CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze 
	更改為這兩句 
	BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
	CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git".freeze
           

改完如下圖。

macOS Catalina 10.15.1安裝homebrew報錯 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

按ESC退出編輯模式,輸入

:wq

退出并儲存。

$ rm -rf /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

// 執行下面這句指令,更換為中科院的鏡像:
$ git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew'...
remote: Counting objects: 656959, done.
remote: Total 656959 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (656959/656959), 213.43 MiB | 2.02 MiB/s, done.
Resolving deltas: 100% (431789/431789), done.
Checking out files: 100% (5104/5104), done.

// 把homebrew-core的鏡像位址也設為中科院的國内鏡像
$ cd "$(brew --repo)" 
Homebrew $ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
Homebrew $ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" 
-bash: cd: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core: No such file or directory
           

報錯:

沒有這個檔案。

解決:

找一下這個目錄:

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

發現這個目錄竟然不存在,那我們就來手動建立一個:

$ sudo mkdir  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
           

再執行一遍:

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

報錯:

還是報homebrew的錯誤,沒辦法,解除安裝了homebrew重新安裝吧。

2、解除安裝homebrew

3、再次安裝homebrew

報錯:

curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
-e:254: unterminated string meets end of file
... "The following existing direct

-e:254: syntax error, unexpected end-of-input, expecting end
           

解決:

應該是這個資源通路有問題,那麼我們可以嘗試使用國内的鏡像。

給大家推薦一個中國科學技術大學的鏡像站點,裡面有各種資源:

https://mirrors.ustc.edu.cn/brew.git

繼續爬坑

第一步:擷取install檔案,把官網給的腳本拿下來
$ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
           
第二步:更改腳本中的資源連結,替換成中國科學技術大學的鏡像
$ vim brew_install
           

進入到brew_install

按 i 進入編輯模式

更改腳本中的資源連結,替換成中國科學技術大學的鏡像
	就是把這兩句 
	BREW_REPO = “https://github.com/Homebrew/brew“.freeze 
	CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze 
	更改為這兩句 
	BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
	CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git".freeze
           

按ESC退出編輯模式,輸入

:wq

退出并儲存。

這個前面已經做過了,不多解釋。

第三步:執行腳本
$ /usr/bin/ruby brew_install
           
報錯:
fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force

           

出現這個原因是因為源不通,代碼來不下來,解決方法就是更換國内鏡像源:

解決:

執行下面這句指令,更換為中國科學技術大學的鏡像:

$  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)" 
Homebrew $ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
Homebrew $ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" 
homebrew-core $ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
           

4、再次更新homebrew

$ brew update
           

這次更新成功。

Updated 1 tap (homebrew/core).
==> Updated Formulae
ansible                    fwup                       mlt
auditbeat                  gatsby-cli                 paket
aws-cdk                    ghq                        picard-tools
aws-sdk-cpp                glib                       redis
breezy                     goreleaser                 reminiscence
ccache                     helmfile                   scrcpy
cheat                      jenkins-lts                serverless
clojure                    jhipster                   swagger-codegen
cointop                    kubebuilder                swagger-[email protected]
convox                     lerna                      synscan
darksky-weather            libimobiledevice           telegraf
diamond                    librealsense               tig
docker-compose-completion  libusbmuxd                 tunnel
elasticsearch              libxlsxwriter              wxpython
exploitdb                  lmod                       zstd
folly                      mesa
           

5、檢查homebrew

$ brew doctor
           

Ps:其實查出一堆Warning,不過不影響使用,這裡暫時不細究了。

6、更換homebrew的預設源:

直接使用 Homebrew 還需要更改預設源,不然誰用誰想打人,原因你懂的。

以下是将預設源替換為國内 USTC 源的方法。

替換核心軟體倉庫

$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
           

替換 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
           

參考文章:

macOS Catalina 10.15.1中安裝Python3 完全安裝攻略

macOS High Sierra10.13.3安裝homebrew報錯LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54解決方法

macOS High Sierra10.13.3安裝homebrew報錯LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54解決方法(和上一篇有一處不同)

Homebrew的安裝、解除安裝和擴充

繼續閱讀