Alexander Gromnitsky's Blog

RVM, Fedora 31 & ancient Ruby 2.0.0

Latest update:

The notion that RVM cannot build old versions of Ruby on modern Fedora versions is understandable but nevertheless ironic, for why would you need an "enVironment Manager [sic]" if it fails to create diverse environments?

A notorious openssl isssue is the culprit. To compile Ruby 2.0.0, you need openssl v1.0.x, but Fedora 31 ships with v1.1.1, & the APIs of these versions are incompatible with each other (so much for semver!) Fedora has a package called compat-openssl10-devel, but it conflicts w/ the usual openssl-devel. You can have different versions of shared opessl libs installed (e.g., via openssl-libs & compat-openssl10 packages) but cannot have both *-devel variants!

Perusing through the rvm repo, I found a list of Ruby binary builds. Fedora's portion of it is lamentable, yet it contains a promising url:

https://rvm_io.global.ssl.fastly.net/binaries/fedora/21/x86_64/ruby-2.0.0-p598.tar.bz2

Turns out, we can manually "mount" (in RVM's terms) such a specially precompiled archive.

Therefore, fetch the tarball, unpack it to, say, ~/opt/s/ & run:

$ rvm mount ~/opt/s/ruby-2.0.0-p598 -n ruby-2.0.0-p598

To check that it all works, especially a tcp socket interface in conjunction w/ ruby-2.0.0-p598/lib/ruby/2.0.0/x86_64-linux/openssl.so (requires compat-openssl10-1.0.2o package installed), use a script:

$ cat openssl-test.rb
require 'socket'
require 'openssl'

puts RUBY_DESCRIPTION

host = ARGV[0] || 'www.twitch.tv'
socket = TCPSocket.new host, 443
ss = OpenSSL::SSL::SSLSocket.new socket, OpenSSL::SSL::SSLContext.new
ss.connect
puts ss.ssl_version

ss << "HEAD /robots.txt HTTP/1.1\r\n"
ss << "Host: #{host}\r\n"
ss << "user-agent: omglol/0.0.1\r\n"
ss << "\r\n"

while (line = ss.gets)
  puts line
  break if line.size <= 2
end

Then

$ rvm use ext-ruby-2.0.0-p598
Using /home/alex/.rvm/gems/ext-ruby-2.0.0-p598
$ ruby openssl-test.rb
ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux]
TLSv1.2
HTTP/1.1 200 OK
...

Tags: ойті
Authors: ag