Posted about 1 month ago. Visible to the public. Linked content.

Installing Ruby 2.3 or below on Ubuntu 17 and above

From Ubuntu 17, rbenv fails to install Ruby below 2.4 because of a mismatching OpenSSL dependency: it needs libssl1.0-dev for the installation process, but recent Ubuntus come with libssl-dev.

From the linked StackOverflow comment:

As far as I know (and tested), Ruby versions < 2.4 requires libssl1.0, while >2.4 libssl1.1+. The two libssl packages conflict with each other, so you can't have both of them, so I had to juggle the libs in order to install the required ruby version. To make things even funnier (or more complicated), Ruby <2.4 tends to require gcc-6 instead of the current upstream version (which is 7).

Install Ruby like this:

Copy
# Ruby 1.8.7 CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with-openssl-dir=/usr/include/openssl" rbenv install 1.8.7-p375 # Ruby 1.9 to 2.3 apt install libssl1.0-dev # This will remove libssl-dev CC=$(which gcc-6) rbenv install $version # Ruby 2.4+ apt install libssl-dev rbenv install $version

Example error backtace

Copy
Checking out http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7... Installing ruby-1.8.7-p375... WARNING: ruby-1.8.7-p375 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates. BUILD FAILED (Ubuntu 18.04 using ruby-build 20180424) Inspect or clean up the working tree at /tmp/ruby-build.20180507142116.3799 Results logged to /tmp/ruby-build.20180507142116.3799.log Last 10 log lines: ^ ossl_ssl.c: In function ‘ossl_ssl_get_cipher’: ossl_ssl.c:1230:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] cipher = SSL_get_current_cipher(ssl); ^ Makefile:198: recipe for target 'ossl_ssl.o' failed make[1]: *** [ossl_ssl.o] Error 1 make[1]: Leaving directory '/tmp/ruby-build.20180507142116.3799/ruby-1.8.7-p375/ext/openssl' Makefile:293: recipe for target 'all' failed make: *** [all] Error 1

You can check installed libssl packages using apt list:

Copy
$ apt list --installed | grep libssl libssl-dev/bionic,now 1.1.0g-2ubuntu4 amd64 [installed] libssl-doc/bionic,bionic,now 1.1.0g-2ubuntu4 all [installed,automatic] libssl1.0.0/bionic,now 1.0.2n-1ubuntu5 amd64 [installed] libssl1.1/bionic,now 1.1.0g-2ubuntu4 amd64 [installed]

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
about 1 month ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more