Search code examples
rubyopensslasdf

Cannot install ruby with asdf on ubuntu


I encountered an error when installing ruby on my Kubuntu 22.04 using asdf. When I ran this code asdf install ruby 2.6.4 The terminal show this and stopped forever:

Downloading ruby-build...
To follow progress, use 'tail -f /tmp/ruby-build.20230227154534.54979.log' or pass --verbose
Downloading openssl-1.1.1t.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b
Installing openssl-1.1.1t...
Installed openssl-1.1.1t to /home/lelouvincx/.asdf/installs/ruby/2.6.4

Downloading ruby-2.6.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.bz2
error: failed to download ruby-2.6.4.tar.bz2

BUILD FAILED (Ubuntu 22.04 using ruby-build 20230222)

Inspect or clean up the working tree at /tmp/ruby-build.20230227154534.54979.cbqQx3
Results logged to /tmp/ruby-build.20230227154534.54979.log

Last 10 log lines:
Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
de0a40|ERR |       0B/s|/tmp/ruby-build.20230227154534.54979.cbqQx3/ruby-2.6.4.tar.bz2

Status Legend:
(ERR):error occurred.

aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.

Please help!

I tried some different tag with openssl like ASDF_RUBY_BUILD_VERSION=master asdf install ruby 2.6.4 or RUBY_CONFIGURE_OPTS=--with-openssl-dir=/opt/openssl-1.1.1n asdf install ruby 2.6.4 but not working too.


Solution

  • Pay attention to these parts:

    Downloading ruby-2.6.4.tar.bz2...
    -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.bz2
    error: failed to download ruby-2.6.4.tar.bz2
    
    ...
    
    Download Results:
    gid   |stat|avg speed  |path/URI
    ======+====+===========+=======================================================
    de0a40|ERR |       0B/s|/tmp/ruby-build.20230227154534.54979.cbqQx3/ruby-2.6.4.tar.bz2
    
    ...
    
    aria2 will resume download if the transfer is restarted.
    

    The problem is not that Ruby will not compile and that's why the flags you added did not change anything. The problem is that Ruby can't be downloaded at all.

    You need to ensure that:

    1. The remote host cache.ruby-lang.org is online
    2. The remote host cache.ruby-lang.org is reachable from your computer

    You can try downloading the file directly with curl:

    curl -O https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.bz2
    

    You should see output like this:

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13.7M  100 13.7M    0     0   9.9M      0  0:00:01  0:00:01 --:--:--  9.9M
    

    And you should have the file ruby-2.6.4.tar.bz2 downloaded as a result. If not then the problem is either 1 or 2 above, and you need to ensure that you are not blocking connections to cache.ruby-lang.org.