Gem install producing “OpenSSL” error

gemopensslruby

For at least a week now i have been trying to install Bettercap on my Raspberry PI using gem but whenever i type in:

sudo gem install bettercap

i receive an error message that says

 ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

Every fix that has been suggested to other people yields no results:

Option 1: "http option"

According to the answer by Filippo De Bortoli in this thread on the same issue, disabling the https protocol will solve it. However after running these commands:

gem source -r https://rubygems.org/ 
gem source -a http://rubygems.org/

I still get this error:

ERROR:  While executing gem ... (Gem::Exception)
        Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

Option 2: rebuild

As suggested by Filippo De Bortoli in the same thread he reinstalled ruby after installing OpenSSL, however my raspbian came with OpenSSL and running sudo apt-get install openssl only confirms i have the latest version. I have also re-built ruby 3 times since i started getting this.

Option 3: install locally

After finding out that you could install the gems locally i installed the source and ran.

sudo gem install --local bettercap-1.6.2b.gem

and got the output:

ERROR:  Could not find a valid gem 'em-proxy' (>= 0.1.8, ~> 0.1) in any repository

I am guessing since it is only searching the local disk it can not find the dependencies it needs, so i decided to locally install "em-proxy" only to find it needed dependencies, which also needed dependencies. Great. So i decided to leave it for the sake of my sanity and it was overall impractical.


To wrap up, how do i get rid of this error or at the very least bypass it?

Just in case you wanted to know here is the output of gem -v:

2.4.5

and the output of ruby -v:

ruby 2.2.2p95 (2015-04-13 revision 50295) [armv6l-linux-eabihf]

Best Answer

Was struggling with this as well when compiling ruby 2.3.6 from source on Debian/Ubuntu. Solved it by install pkg-config additionally to libssl-dev, e.g. the full instructions:

$ sudo apt install \ make \ gcc \ pkg-config \ libssl1.0-dev \ libreadline-dev \ libgdbm-dev \ zlib1g-dev \ libyaml-dev \ libffi-dev \ libgmp-dev \ openssl $ ./configure --disable-install-rdoc $ make -j2 $ sudo make install

Note, that the libssl-dev package is not compatible with ruby2.3 (see: https://github.com/rvm/rvm/issues/3862#issuecomment-277512130) so on Debian/Stretch or Ubuntu/Xenial you need to install libssl1.0-dev instead.

Related Question