非墙安装homebrew/解决 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation time...

温馨提示:可墙小伙伴绕行

0、官方推荐安装方法

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1.更换镜像源安装

打开终端输入:

$ /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

2.进入漫长的等待过程.....期间需要输入回车和开机密码
之后会自动安装一个Xcode Command Line Tool。
安装完后需要重回终端输入回车,接着下载等待,终端显示如下

==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 77, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (44/44), done.
Receiving objects:  24% (167311/687566), 38.70 MiB | 7.00 KiB/s  

Tips:若源不对,可能会卡在了这个位置超时报错。若未报错则等待安装成功即可。

==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 77, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (44/44), done.
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
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.
Failed during: /usr/local/bin/brew update --force
LNdeMacBook-Pro:Desktop ln$ 

解决方法:终端键入如下代码

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

回车后提示成功如下

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 5144, done.
remote: Compressing objects: 100% (4945/4945), done.
remote: Total 5144 (delta 40), reused 884 (delta 3)
Receiving objects: 100% (5144/5144), 4.18 MiB | 1.61 MiB/s, done.
Resolving deltas: 100% (40/40), done.

再次终端输入以下命令,每行输入完后回车

$ 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

2.更新homebrew

$ brew update
  • 可能会报错如下,如未报错 忽略即可。
Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
Failed during: /usr/local/bin/brew update --force --quiet
  • 解决办法,cmd+shift+G,输入/usr/local/Homebrew/Library/Taps/homebrew,回车,删除homebrew-core,再次终端执行
$ brew update

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1179903, done.
remote: Counting objects: 100% (136/136), done.
remote: Compressing objects: 100% (98/98), done.
Receiving objects:   1% (15390/1179903), 12.96 MiB | 47.00 KiB/s

提示安装成功

Already up-to-date.

3.安装成功后查看当前安装版本

$ brew -v
Homebrew 2.2.7
Homebrew/homebrew-core (git revision 467d; last commit 2020-03-03)

参考文章
mac下镜像飞速安装Homebrew教程

你可能感兴趣的:(非墙安装homebrew/解决 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation time...)