20

Getting few errors while installing ruby-2.1.2 using rvm. I am new to ruby and hence need assistance. Please let me know

Installation log and other relevant information here: log

From the log provided in problem description, I have ruby 2.1.2 installed in the system. However, getting error when tried listing gems with gem list due to installation errors.After changing to 2.1.2 i.e., rvm use 2.1.2 and executing ruby -r openssl -e 'puts OpensSSL::OPENSSL_VERSION' gives this error:

/Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- openssl (LoadError) from /Users/praveenk.k/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require'

5
  • 1
    OpenSSL is proably not on your machine. Check if it is there with which openssl. Commented Dec 16, 2019 at 5:23
  • which openssl prints the output /usr/local/opt/[email protected]/bin/openssl . Hence I assume I have openssl present in my system. Commented Dec 16, 2019 at 7:00
  • OK, your issue seems to not be an openssl issue. What you can try next: look at file /Users/praveenk.k/.rvm/log/1576471018_ruby-2.1.2/gem.install.gem-wrappers->=1.4.0.log. Share the Content of this file with us. Commented Dec 16, 2019 at 8:18
  • contents of cat "/Users/praveenk.k/.rvm/log/1576471018_ruby-2.1.2/gem.install.gem-wrappers->=1.4.0.log" is like this: ERROR: Loading command: install (LoadError) cannot load such file -- openssl ERROR: While executing gem ... (NoMethodError) undefined method invoke_with_build_args' for nil:NilClass` Commented Dec 16, 2019 at 8:30
  • 1
    Please put the text of your last comment in your original post. This way it is easier for people to help you. Commented Dec 16, 2019 at 12:19

7 Answers 7

28

Worked example

brew install rbenv/tap/[email protected]
rvm install 2.1.2 -C --with-openssl-dir=`brew --prefix [email protected]`

It's from https://github.com/rvm/rvm/issues/4819#issuecomment-595644550

17

Ruby <2.4 is incompatible with OpenSSL 1.1 (e.g see https://github.com/rbenv/ruby-build/issues/1353).

Just a hunch, but if you're using Mac + Homebrew, OpenSSL 1.0 was recently deleted, so anything along the lines of brew upgrade openssl would trash that.

There are several options to deal with this:

  1. I have older Rubies via asdf installed with LibreSSL (which may be safer anyway, see https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):
$ openssl
OpenSSL> version
LibreSSL 2.8.3
  1. Compile and link your own OpenSSL 1.0 (or then set compiler flags as environment variables when building Ruby -- https://rvm.io/rubies/installing)
  2. See if your system's package manager allows you to access openssl 1.0 and install with that (was helping a coworker with this recently and we weren't able to find a good keg for homebrew at this time, unfortunately)

There might be something less convoluted than that; if someone has ideas, please feel free to comment or give an alternate answer.

EDIT

I personally ran into this issue with some other software and discovered that this fixed it, since the old SSL version was sitting around still:

brew switch openssl 1.0.2s

Should work so long as Homebrew doesn't "helpfully" clean that out for me.

2
  • 3
    that really helped! I followed this link Commented Dec 17, 2019 at 12:18
  • 3
    "brew switch openssl 1.0.2s" gives "Error: Unknown command: switch"
    – Dave
    Commented Jan 21, 2022 at 15:41
12

For debian 10 :

sudo apt-get install -y libssl-dev

7

On mac BigSur, I fixed it via

$ rvm pkg install openssl
$ rvm install 2.1.2 -C --with-openssl-dir=$HOME/.rvm/usr

or you can also try with

$ rvm pkg install openssl
$ CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.1.2 -C --with-openssl-dir=$HOME/.rvm/usr

1
  • First approach worked on Mojave. Thank you!
    – Vibin
    Commented Sep 2, 2023 at 14:35
1

For me solve this in centos 7

$ openssl version -a


OpenSSL 1.0.2k-fips  26 Jan 2017
built on: reproducible build, date unspecified
platform: linux-x86_64
options:  bn(64,64) md2(int) rc4(8x,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: gcc -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM

------------------------------------------------------------------------
OPENSSLDIR: "/etc/pki/tls" <- ************* COPY THIS PATH *************
------------------------------------------------------------------------

engines:  rdrand dynamic 

paste the path in the bellow line how --with-openssl-dir param

$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=/etc/pki/tls" rbenv install 2.7.2
1

On Mac OS X Big Sur, to install Ruby 2.3.2 with RVM, the fix was

brew install rbenv/tap/[email protected]
CFLAGS="-Wno-error=implicit-function-declaration" rvm reinstall ruby-2.2.5 --with-openssl-dir='/usr/local/opt/[email protected]'

Reference was here -- https://github.com/rvm/rvm/issues/4889

0

On Amazon Linux 2, even if openssl is installed, you need the full dev kit

yum install openssl-devel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.