9

I've had some problems building older versions of Ruby with ruby-install on Archlinux. I suspect the same is happening with ruby-build. I am seeing the following after trying to install Ruby 2.1.5, 2.1.6, 2.3.0, 2.3.1, 2.3.4.

/usr/include/openssl/asn1_mac.h:10:2: error: #error "This file is obsolete; please update your software."
#error "This file is obsolete; please update your software."

or

ossl_ssl.c:465:38: error: ‘CRYPTO_LOCK_SSL_SESSION’ undeclared
PhilT
  • 4,166
  • 1
  • 36
  • 26

2 Answers2

25

If not already installed you need Open SSL 1.0:

pacman -S openssl-1.0

For installing Ruby 2.3.x the following is needed:

PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install ruby 2.3.0

I installed 2.3.0, 2.3.1 and 2.3.4 this way.

I'm using ruby-install but the same probably applies to ruby-build (rbenv).

For Ruby 2.1.x and 2.2.x a patch is also needed:

curl -fsSL https://gist.github.com/mislav/055441129184a1512bb5.txt > ruby2.x-openssl.patch
PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install -p ruby2.x-openssl.patch ruby 2.1.5

I installed 2.1.5 and 2.1.6 this way.

For older versions of Ruby (< 2) a different patch may be needed which can be downloaded here:

https://github.com/rbenv/ruby-build/wiki#openssl-sslv3_method-undeclared-error

Corrupted memory and Segfaults when compiling ruby

If you get segfaults when compiling, it might be because of the latest version of gcc. A workaround is to install an older version and then specify it to ruby-install:

sudo pacman -S gcc5
CC=/usr/sbin/gcc-5 PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install ruby 2.3.0

Reference: https://github.com/rbenv/ruby-build/issues/1092

PhilT
  • 4,166
  • 1
  • 36
  • 26
  • 2
    Once `openssl-1.0` is installed the environment variable works with `rbenv` too, e.g. `PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig rbenv install 2.3.0`. – ChrisGPT was on strike May 24 '17 at 00:25
  • That's what I meant by `ruby-build`. Thanks for confirming @Chris – PhilT May 25 '17 at 06:29
  • 1
    Unless I am mistaken, updating pacman's package cache without also updating your packages can lead to an inconsistent state. You should be using either `pacman -Syyu openssl-1.0` or `pacman -S openssl-1.0`. – alecdwm Jun 28 '17 at 10:54
  • You are indeed correct. I've got aliases setup so don't normally run it bare. Thanks! – PhilT Jun 28 '17 at 12:42
0

Same worked for me with Ruby 2.6 and OpenSSL 1.1 using rvm:

pacman --sync --needed openssl-1.1
PKG_CONFIG_PATH=/usr/lib/openssl-1.1/pkgconfig rvm install 2.6
Bruno Medeiros
  • 2,251
  • 21
  • 34