Debugging the OpenSSL problem with Ruby gem set-up
When I first had to set up my Ruby gem, it was the most confusing time of my whole coding learning experience, as I learn to use command line control, having GitHub blocked in China, and set up the Ruby, rvm, gem plus others, all on the same night.
After successfully install Ruby, I could never get through the gem installation. Two types of error keep coming up:
$gem install (whatever, bundler, jekyll.. etc)
ERROR : While executing gem … (Gem::Exception) Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources $gem source -l
ERROR: Could not find a valid gem ‘learn-co’ (>= 0) in any repository
None of the stackoverflow (after reading through dozens) had the answer all in the same place. Here is the synthesis of RIGHT answer.
Problem 1. The newer versions of OSX deprecated openSSL.
Solution: reinstall ruby specifying exactly where the openSSL libraries are for it to be compiled.
$ brew install openssl
$ rvm reinstall 2.3.0 — with-openssl-dir=`brew — prefix openssl`
Problem 2. Ruby by default adds a secure HTTPS connection as source.
First check $gem sources, if the current sources are empty, addmanually the correct source.
$ gem sources — add https://rubygems.org/
NOW THE SHORTCUT :)
But.. if you are looking for a one-second solution, scrap all the things I said above. Just simple install the 2.5.3 version of rvm.
$ rvm install 2.5.3
The problem may come up again as your system defaults to the older version. Simple set 2.5.3 as default.
$ rvm use 2.5.3 — default