There is an issue with installing ruby on ubuntu 22.04 with rvm as it will give you error below
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?