erlangasdf-vm

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


Background

I have a Ubuntu and I am trying to install Erlang 22.2.8 via the asdf-erlang plugin.

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

Problem

In fact, I want to install any version of Erlang, but none works.

$ asdf install erlang 22.2.8
Downloading kerl...
$

It stops after "Downloading kerl" and then nothing happens. It is like it finished. I have followed the steps before-asdf-install also before installing the plugin, but non the less this does not prevent the error.

How can I fix this?


Solution

  • After a lot of investigation by me and several people from the Elixir community, we have finally discovered what was the issue.

    Issue

    The first clue was the exit signal of the command itself:

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

    The exit code is 1. Which means an error was occurring.

    So after digging into the code, we found there was a curl call I was not able to make:

    $ 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
    

    I was having SSL certificate issues. This is happening because of the company VPN/Proxy.

    A quickfix/workaround could be found using the -k option to allow the curl to connect to insecure connections. After trying that curl with -k the request succeeded, which proved the theory correct.

    Solution

    With the issue identified, it was time to search for a solution. The solution I believe would be the most adequate, would be to add the company certificates to ssl certs.pem. This is described better in the following SO post:

    How to fix "SSL certificate problem: self signed certificate in certificate chain" error?

    Quick workaround

    However, that solution didn't work me. So I eventually decided to go with the risky option, which was to use the ~/.curlrc.

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

    After setting up this file and adding the -k option in it, it worked. I can now finally install the erlang versions I need.

    It should be noted, this is a risk. In fact, this is a workaround and not really a solution.

    However, for the time being, I will happily take it.

    History

    This is a summary of the whole discussion I had with the Elixir community. If you are interested in the full process, you can check the post:

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