21

I recently updated my system to Ubuntu 18.04 LTS, and since then, the Ruby version seems to have updated to 2.5. The issue is that, when attempting to deploy a project that uses Capistrano, it will now complain that Ruby 2.3 was not found.

The version it tries to install when running rvm install 2.3 is 2.3.4, and the first error that is shown is "Error running '__rvm_make -j4'". I tried removing RVM and installing again, but nothing solves this. The log is an enormous file which tells me nothing.

Then, I tried using rbenv, which also causes an error:

Installing ruby-2.3.4...

BUILD FAILED (Ubuntu 18.04 using ruby-build 20180424)

Inspect or clean up the working tree at /tmp/ruby-build.20180429172721.16258
Results logged to /tmp/ruby-build.20180429172721.16258.log

Last 10 log lines:
installing default nkf libraries
linking shared-object objspace.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/objspace'
linking shared-object pathname.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/pathname'
linking shared-object nkf.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/nkf'
make[1]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

The log file also has a stupid giant log file.

The next attempt was to install from source, which after running make within the folder, the error:

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/x509_vfy.h:17,
                 from openssl_missing.c:15:
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);
      ^
openssl_missing.c:39:23: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
 EVP_MD_CTX_create(void)
                       ^
openssl_missing.c:40:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
openssl_missing.c: In function ‘EVP_MD_CTX_cleanup’:
openssl_missing.c:55:27: error: invalid application of ‘sizeof’ to incomplete type ‘EVP_MD_CTX {aka struct evp_md_ctx_st}’
     memset(ctx, 0, sizeof(EVP_MD_CTX));
                           ^~~~~~~~~~
In file included from /usr/include/openssl/x509.h:23:0,
                 from /usr/include/openssl/x509_vfy.h:17,
                 from openssl_missing.c:15:
openssl_missing.c: At top level:
openssl_missing.c:63:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
 EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
 ^
openssl_missing.c:72:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
 EVP_MD_CTX_init(EVP_MD_CTX *ctx)
 ^
openssl_missing.c: In function ‘HMAC_CTX_init’:
openssl_missing.c:82:25: error: dereferencing pointer to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
     EVP_MD_CTX_init(&ctx->i_ctx);
                         ^
openssl_missing.c: In function ‘HMAC_CTX_cleanup’:
openssl_missing.c:95:27: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
     memset(ctx, 0, sizeof(HMAC_CTX));
                           ^~~~~~~~
Makefile:301: recipe for target 'openssl_missing.o' failed
make[2]: *** [openssl_missing.o] Error 1
make[2]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7/ext/openssl'
exts.mk:212: recipe for target 'ext/openssl/all' failed
make[1]: *** [ext/openssl/all] Error 2
make[1]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

What is it there to be done to install it? Or it isn't possible anymore to install these old versions?

9 Answers9

51

I had a same issue, though it seemed problem was in gcc, in my case problem was in libssl-dev, this is what helped me:

sudo apt purge libssl-dev && sudo apt install libssl1.0-dev

I use rbenv. If you use rvm, you might hit problem after running previous command:

/usr/share/rvm/scripts/base: No such file or directory

I recommend trying rbenv. After installing libssl1.0-dev, everything was flawless.

guitarman
  • 641
  • 4
  • 5
  • 5
    There is one more thing to mention. I think when you want to install newer version of ruby later in the future, there is a chane you will be missing `libssl-dev` (the original one) – guitarman May 03 '18 at 07:30
  • 3
    rbenv 2.3.1 and 2.2.5 installed successfully, thank you! – Nezir May 29 '18 at 13:54
  • 1
    **Ubuntu 19.10:** Here, there is still `libssl1.0` but no longer a `libssl1.0-dev`, which seems to be a mistake. It is possible to use the version from Ubuntu 18.04 ([instructions](https://github.com/rvm/rvm/issues/4680#issuecomment-545827499)). – tanius Mar 29 '20 at 20:47
  • @tanius Thanks for update! I am still on Ubuntu 18.04 personally, so I did not notice this. – guitarman Mar 30 '20 at 08:21
  • 1
    **Ubuntu 20.04** works with the same instructions that work for 19.10. Just make sure you "sudo apt-get install build-essential" and rbenv will guide you on what are the missing dependencies. – corlaez Apr 24 '20 at 05:37
  • 1
    I am getting this error `package 'libssl1.0-dev' has no installation candidate` – shah Jul 10 '20 at 06:25
14
cd ~/src
 wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
 tar xvzf openssl-1.0.2s.tar.gz
 cd openssl-1.0.2s
 mkdir ~/.rubies/openssl-1.0.2s
 ./config --prefix=$HOME/.rubies/openssl-1.0.2s --shared
 make
 make install
 RUBY_CONFIGURE_OPTS=--with-openssl-dir=$HOME/.rubies/openssl-1.0.2s rbenv install 2.3.1

worked for me

Stefan
  • 508
  • 5
  • 9
  • 1
    For those using [ruby-install](https://github.com/postmodern/ruby-install), usually with [chruby](https://github.com/postmodern/chruby), the last line will be this instead: `ruby-install ruby 2.3.1 -- --with-openssl-dir=$HOME/.rubies/openssl-1.0.2s` – tanius Mar 29 '20 at 02:56
  • Nice answer because it is a full recipe which leaves no detail open. – TNT Oct 28 '20 at 16:59
  • 1
    Older openssl versions are no longer available around the default apt repos so this is actually the best way to make it happen. – Roberto Decurnex Feb 11 '21 at 12:57
  • It is definitely an openssl version issue. This solution worked for an asdf install of ruby 2.2.4 on Ubuntu 20.04, just replace the `rbenv install 2.3.1` in the above command with `asdf install ruby ` – Daniel Nalbach Aug 25 '21 at 22:50
  • My recent Archlinux OpenSSL broke Ruby 2.7.2 installed with RVM. This was the solution, but there was a difference: `--with-openssl-dir=/tmp/rb-openssl-1.0.2s/`. Here I used `--prefix=/tmp/rb-openssl-1.0.2s/` instead. But the option is appended to the `rvm install` or `reinstall` command. – 15 Volts Nov 06 '22 at 09:05
6

Got it working also with RVM:

1. sudo apt purge libssl-dev && sudo apt install libssl1.0-dev 2. rvm install 2.3.5 --autolibs=disable

You must install RVM dependencies manually, otherwise, with autolibs enabled, RVM will try to update system dependencies and also libssl-dev (that you downgraded in the first step). If you don't want to manually install dependencies you can try to install Ruby with autolibs enabled, the installation will fail, at this point you have dependencies installalled, so you can downgrade libssl repeating all from step 1.

Samuele Bistoletti
  • 199
  • 1
  • 1
  • 7
4

Solved that issue by updating rvm rvm get head

SERGHII
  • 64
  • 5
  • This worked for me installing ruby 2.2.10 on 18.04. It took care of the patches itself. -- Please be aware that you just installed a ruby that requires 1 patches just to be compiled on an up to date linux system. This may have known and unaccounted for security vulnerabilities. Please consider upgrading to ruby-2.5.1 which will have all of the latest security patches. – olore Jun 11 '18 at 04:51
  • Your message is more about ruby, not rvm. – SERGHII Jun 21 '18 at 20:52
1

In order to install libssl-dev on Ubuntu 20.04. Use this command to to do that. It worked for me: sudo apt install libssl-dev/focal

Babatunde Mustapha
  • 2,131
  • 20
  • 21
0

I have a similar problem. Apparently the ruby version < 2.3 is incompatible with openssl 1.1 which come with the lastest versions of Ubuntu. Here i found a solution for ArchLinux, I tried this solution and ruby compiled fine, but i had a lot memory bugs in rails then my unique solution for now is use ruby > 2.4 until i found other solution.

Armando
  • 940
  • 7
  • 16
0

OpenSSL 1.1 isn’t compatible with Ruby 2.3.x checkout this issue here

I solved the issue on mac by using following command.

rvm reinstall ruby-2.3.8 --with-openssl-dir=`brew --prefix openssl@1.0` --debug

You can solve it in similar way for ubuntu by installing openssl@1.0

Vishal Jain
  • 446
  • 3
  • 7
0

As of this posting, on Ubuntu 22.04 the following - a combination of solutions above - worked for me to install an older build of Ruby 2.7 for an OSS contribution using rbenv:

brew install openssl@1.1
RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl@1.1` rbenv install 2.7.6
Heath
  • 2,986
  • 18
  • 21
-1

Try this with rvm

rvm install ruby-2.3.4

Or perhaps try https://gorails.com/setup/ubuntu/18.04

You probably are missing required libraries so try running these first:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs yarn
lacostenycoder
  • 10,623
  • 4
  • 31
  • 48