在 Ubuntu 上通过 asdf 安装 Erlang 在 "Downloading kerl" 后失败

Installing Erlang via asdf on Ubuntu fails after "Downloading kerl"

背景

我有一个 Ubuntu,我正在尝试通过 asdf-erlang plugin.

安装 Erlang 22.2.8
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

问题

事实上,我想安装任何版本的 Erlang,但是 none 可以。

$ asdf install erlang 22.2.8
Downloading kerl...
$

它在“正在下载kerl”后停止,然后什么也没有发生。就像完成了一样。 在安装插件之前,我也已经按照步骤 before-asdf-install 进行操作,但这并不能防止错误。

我该如何解决这个问题?

经过我和 Elixir 社区的几个人的大量调查,我们终于发现了问题所在。

问题

第一个线索是命令本身的退出信号:

$ asdf install erlang 22.2.8
Downloading kerl...
$ echo $?
1

退出代码为 1。这意味着发生错误。

所以在深入研究代码后,我们发现有一个 curl 调用我无法进行:

$ curl -v -Lso ~/.asdf/plugins/erlang/kerl https://raw.githubusercontent.com/kerl/kerl/2.0.2/kerl
*   Trying 151.101.16.133:443...
* TCP_NODELAY set
* Connected to raw.githubusercontent.com (151.101.16.133) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [6 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [3400 bytes data]
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
} [2 bytes data]
* SSL certificate problem: self signed certificate in certificate chain
* Closing connection 0

我遇到了 SSL 证书问题。这是因为公司 VPN/Proxy.

可以使用 -k 选项找到 quickfix/workaround 以允许 curl 连接到不安全的连接。在尝试使用 -k 进行卷曲后,请求成功,证明理论正确。

解决方案

确定问题后,是时候寻找解决方案了。我认为最合适的解决方案是将公司证书添加到 ssl certs.pem。这在以下 SO post:

中有更好的描述

快速解决方法

但是,该解决方案对我不起作用。所以我最终决定采用有风险的选择,即使用 ~/.curlrc.

https://ec.haxx.se/cmdline/cmdline-configfile#default-config-file

设置此文件并在其中添加 -k 选项后,它起作用了。我现在终于可以安装我需要的 erlang 版本了。

需要注意的是,这是一个风险。事实上,这是一种变通方法,并不是真正的解决方案

不过,暂时我还是乐意接受的。

历史

这是我与 Elixir 社区的整个讨论的总结。如果您对完整过程感兴趣,可以查看post:

https://elixirforum.com/t/installing-erlang-via-asdf-on-ubuntu-fails-after-downloading-kerl/36806/25