Upgrade your rubies < 2.4 with rvm on Archlinux

I previously wrote about it in a toot on mastodon. As this toot was incomplete, I prefer precise it here. The solution described here was found by rando on the official archlinux forum.

Some time ago, Archlinux switch to openssl 1.1. I’ll not discuss here the good or the bad of such a move, neither will I speak about the various crash it leads to (spotify, steam…). In fact, all the broken packages were AUR packages and proprietary stuff, often statically compiled against some libs and arbitrary depending on some others. In a perfect world, we do not have such a problem for these software as we should be able to compile them as we wish. But that is not the subject.

One of the collateral victim of this switch is the ruby ecosystem. Yes, if you do the things rights (and of course you do it), you don’t use the official ruby package, but one of the various userland ruby environment tools (rvm, rbenv…). If you do, you already know that each new openssl version obliged us to recompile our rubies. That was this easy: rvm reinstall myruby

But with the openssl switch, we discover a bad situation: it is impossible to compile ruby version inferior to the 2.4 with openssl 1.1. If you have, like me, to maintain an application using ruby 2.1, 2.2 or 2.3, it became suddenly impossible to compile it.

After a long quest around the various compilation option and way to pass it to make through rvm, I finally found the solution.

First, you must have installed openssl-1.0. Because we will build our rubies against it. Yes, you can have both openssl-1.0 and openssl installed on your system. Then, all we have to do is to export a bunch of variables before doing our rvm reinstall:

$ export PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig
$ export CFLAGS="$CFLAGS -I/usr/include/openssl-1.0"
$ export LDFLAGS="$LDFLAGS -L/usr/lib/openssl-1.0 -lssl"
$ rvm reinstall ruby-2.1.2

And now you should have your ruby 2.1.2 running as before. You don’t need to pass any other environment variable before running it. You may have to reinstall some of your gem after that thought, and in most of the cases, it should be fixed with a simple bundle install in your project repository.

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

Ajouter un rétrolien

URL de rétrolien : https://etienne.depar.is/a-ecrit/trackback/560