Como instalar ruby 2.3.x no Linux

#dev, #ruby, #unix

Ultimamente sempre que instalo uma versão 2.3.x do Ruby eu recebo um erro similar a este:

linking shared-object objspace.so
make[2]: Leaving directory '/home/dmitry/src/ruby-2.3.6/ext/objspace'
make[2]: Entering directory '/home/dmitry/src/ruby-2.3.6/ext/openssl'
compiling ossl_ocsp.c
In file included from ossl.h:57:0,
                 from ossl_ocsp.c:11:
/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."
  ^~~~~
In file included from ossl.h:222:0,
                 from ossl_ocsp.c:11:
openssl_missing.h:78:35: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
 EVP_MD_CTX *EVP_MD_CTX_create(void);
                                   ^
In file included from /usr/include/openssl/x509.h:23:0,
                 from /usr/include/openssl/x509v3.h:14,
                 from ossl.h:58,
                 from ossl_ocsp.c:11:
openssl_missing.h:82:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
      ^
openssl_missing.h:90:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
      ^
ossl_ocsp.c: In function ‘ossl_ocspbres_add_status’:
ossl_ocsp.c:716:35: error: dereferencing pointer to incomplete type ‘OCSP_SINGLERESP {aka struct ocsp_single_response_st}’
  sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
                                   ^~
ossl_ocsp.c: In function ‘ossl_ocspcid_get_serial’:
ossl_ocsp.c:974:33: error: dereferencing pointer to incomplete type ‘OCSP_CERTID {aka struct ocsp_cert_id_st}’
     return asn1integer_to_num(id->serialNumber);
                                 ^~
make[2]: *** [Makefile:302: ossl_ocsp.o] Error 1
make[2]: Leaving directory '/home/dmitry/src/ruby-2.3.6/ext/openssl'
make[1]: *** [exts.mk:212: ext/openssl/all] Error 2
make[1]: Leaving directory '/home/dmitry/src/ruby-2.3.6'
make: *** [uncommon.mk:203: build-ext] Error 2
!!! Compiling ruby 2.3.6 failed!

Se você está usando Linux a solução para isso é configurar a variável PKG_CONFIG_PATH.

$ PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install ruby-2.3.0
  • Usando ./configure && make && make install fica algo como:
$ /configure --prefix=${HOME}/local/ruby-2.3.6
$ PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig make
$ make install

Seguindo a thread linkada nas referências pode-se usar solução semelhante para o rbenv.

Referências