skip to Main Content

There is an issue with installing ruby on ubuntu 22.04 with rvm as it will give you error below
enter image description here

Error running '__rvm_make -j8',
please read /usr/share/rvm/log/1655413907_ruby-2.5.0/make.log

There has been an error while running make. Halting the installation.

The same error if I try to install ruby 2.7.0, 2.7.1. 2.7.2 and higher.

I have found the suggestion here to use the following steps

rvm pkg install openssl

rvm remove x.x.x

rvm install x.x.x -C –with-openssl-dir=$HOME/.rvm/usr

This makes installation successful but then some libraries like pg or rails or puma do not work with ruby version that was installed this way. For example after bundle install if you run command ‘rails db:migrate’ it will give you another error from pg gem – Segmentation fault

/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record.rb:113: [BUG] Segmentation fault at 0x00007f03df83e140
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0011 p:0009 s:0055 e:000053 METHOD /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record/entry.rb:53
c:0010 p:0014 s:0047 e:000046 METHOD /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record/entry.rb:18
c:0009 p:0039 s:0042 e:000041 METHOD /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record.rb:100
c:0008 p:0070 s:0034 e:000033 METHOD /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record.rb:68
c:0007 p:0009 s:0028 e:000027 BLOCK  /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:76
c:0006 p:0017 s:0025 e:000024 METHOD /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:103
c:0005 p:0008 s:0018 e:000017 BLOCK  /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:76 [FINISH]
c:0004 p:---- s:0014 e:000013 CFUNC  :each
c:0003 p:0011 s:0010 e:000009 BLOCK  /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:75 [FINISH]
c:0002 p:0007 s:0006 e:000005 BLOCK  /usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb:6 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb:6:in `block in add'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:75:in `block in start'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:75:in `each'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:76:in `block (2 levels) in start'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:103:in `_timed'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/adapter/base.rb:76:in `block (3 levels) in start'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record.rb:67:in `build'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record.rb:102:in `_fast_build_dir'
/usr/share/rvm/gems/ruby-2.5.0/gems/listen-3.1.5/lib/listen/record/entry.rb:18:in `children'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f03df83e140 RBP: 0x000055e2c1faa3e8 RSP: 0x00007ffcb2ab4718
 RAX: 0x0000000000000000 RBX: 0x00007f03df8412c0 RCX: 0x0000000000000000
 RDX: 0x000055e2bc30f010 RDI: 0x000055e2c1faa6c0 RSI: 0x000055e2c260c540
  R8: 0x0000000000000000  R9: 0x0000000000000000 R10: 0x00007f03dff62630
 R11: 0x00007f03e0076890 R12: 0x000055e2c1faa3e0 R13: 0x00007f03dfd83b10
 R14: 0x0000000000000000 R15: 0x000055e2c2670fd0 EFL: 0x0000000000010202

-- C level backtrace information -------------------------------------------
Unexpected size of .debug_line in /usr/share/rvm/rubies/ruby-2.5.0/bin/ruby
/usr/share/rvm/rubies/ruby-2.5.0/lib/libruby.so.2.5(rb_vm_bugreport+0x4ae) [0x7f03e16b18ce]
/usr/share/rvm/rubies/ruby-2.5.0/lib/libruby.so.2.5(0xaafbd) [0x7f03e152ffbd]
/usr/share/rvm/rubies/ruby-2.5.0/lib/libruby.so.2.5(0x19e2e6) [0x7f03e16232e6]
/lib/x86_64-linux-gnu/libc.so.6(0x7f03e128e520) [0x7f03e128e520]
/lib/x86_64-linux-gnu/libssl.so.3(0x7f03df83e140) [0x7f03df83e140]

According to this postenter link description here this issue with pg gem is also releted to openssl version

So both of these issues are related to OpenSSL version that comes with ubuntu 22.04 but I cannot find any guide that explains step-by-step how to fix it or how to use the older OpenSSL version for ruby installation that will work without all these errors.

So what are the correct steps to install ruby on Ubuntu 22.04?

5

Answers


  1. Chosen as BEST ANSWER

    I have found a solution to this problem. To fix it you need to install libssl1.0-dev and remove the current version of libssl-dev. So if you need to install ruby 2.7.1 for example, you will have to execute these two commands

     sudo apt purge libssl-dev && sudo apt install libssl1.0-dev
     rvm install 2.7.1
    

  2. After following pretty much what you went though, I was at the point of considering to downgrade the whole system. Luckily, i found this article

    https://deanpcmad.com/2022/installing-older-ruby-versions-on-ubuntu-22-04/

    And decided to give it one last chance. Author is using there tool called asdf, but there is a note, that same configuration should work with rbenv. I run rvm implode, installed rbenv, installed gems and started rails server.

    And it worked! Not sure what is wrong with rvm, wither it is its fault or OpenSSL mismatch, but currently I want to focus on coding and that’s it.

    Hope that will help somebody to make further research.

    Login or Signup to reply.
  3. I had the same problem, and the best solution was to use the rbenv instead of rvm.
    You won’t need to downgrade the openssl version of Ubuntu 22.04, because the rbenv already download and use the openssl 1.1.1 for your ruby version.

    Install rbenv
    https://github.com/rbenv/rbenv
    with ruby-build as plugin
    https://github.com/rbenv/ruby-build

    My versions (Openssl, Ruby and Rbenv)
    enter image description here

    Login or Signup to reply.
  4. What works for me is to run

    rvm pkg install openssl

    and then

    rvm install ruby-2.7.3 --with-openssl-dir=$HOME/.rvm/usr

    Hope it helps!

    Login or Signup to reply.
  5. Most people who arrive here from Google are likely running the following:

    rvm install ruby
    

    As of writing, this will install ruby 3.0.0 which will give you a build error on Ubuntu 22.04.

    Most people probably want to install the latest 3.1.0, which does not show when running rvm list known.

    To install the latest (which is currently 3.1.0) run:

    rvm install ruby-3.1.0
    

    The latest will install fine on Ubuntu 22.04.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search