Eric's Blog 时光荏苒,岁月如梭

修复 git clone 问题: gnutls_handshake() failed

2024-02-23
Eric Wong

前因

今天在 wsl 内将 ~/.SpaceVim 仓库的远程地址设置成 https://spacevim.org/git/repos/SpaceVim/ 后,再执行 git pull 出现错误:

fatal: unable to access 'https://spacevim.org/git/repos/SpaceVim/': gnutls_handshake() failed: Error in the pull function.

但是,恢复成 github 或者 gitlab 仓库地址后,就又可以执行 git pull 了。

尝试诊断

执行如下命令,看看网络链接到底怎么回事:

GIT_CURL_VERBOSE=1 git pull

输出为:

23:29:04.865626 http.c:664              == Info: Couldn't find host spacevim.org in the (nil) file; using defaults
23:29:04.884061 http.c:664              == Info:   Trying 104.21.53.107:443...
23:29:05.085433 http.c:664              == Info:   Trying 2606:4700:3037::ac43:d405:443...
23:29:05.085549 http.c:664              == Info: Immediate connect fail for 2606:4700:3037::ac43:d405: Network is unreachable
23:29:05.085601 http.c:664              == Info:   Trying 2606:4700:3032::6815:356b:443...
23:29:05.085623 http.c:664              == Info: Immediate connect fail for 2606:4700:3032::6815:356b: Network is unreachable
23:29:05.118268 http.c:664              == Info: Connected to spacevim.org (104.21.53.107) port 443 (#0)
23:29:05.138108 http.c:664              == Info: found 372 certificates in /etc/ssl/certs
23:29:05.138186 http.c:664              == Info: GnuTLS ciphers: NORMAL:-ARCFOUR-128:-CTYPE-ALL:+CTYPE-X509:-VERS-SSL3.0
23:29:05.138223 http.c:664              == Info: ALPN, offering h2
23:29:05.138240 http.c:664              == Info: ALPN, offering http/1.1
23:29:05.149601 http.c:664              == Info: gnutls_handshake() failed: Error in the pull function.
23:29:05.149680 http.c:664              == Info: Closing connection 0
fatal: unable to access 'https://spacevim.org/git/repos/SpaceVim/': gnutls_handshake() failed: Error in the pull function.

重新编译

删除已有 git:

sudo apt uninstall git

下载 git 源码

wget "https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.xz"
tar -xvf git-2.9.5.tar.xz

安装依赖

sudo apt-get update
sudo apt-get install curl jq -y
sudo apt-get install build-essential autoconf dh-autoreconf -y
sudo apt-get install libcurl4-openssl-dev gettext -y

编译

make configure
./configure --prefix=/usr --with-openssl
make -j4

安装

sudo make install

分享到:

评论

目前只支持使用邮件参与评论。

目录