12
votes

I've hit the problem of setup of RVM + Rubies on a new Mac laptop where after getting RVM installed plus Homebrew the install for Rails hits the error:

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

Background and Environment

Discoveries & Fault Diagnosis

Starting with a clean laptop I had followed the usual path of installing Homebrew, Xcode command line tools, MySQL (for rails dev), Git and then RVM. Even with the environment variables set and also uninstalling and rebuild of RVM, removing and re-adding OpenSSL within Homebrew, when trying to get Rails installed I'm greeted with the error:

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

The other item to note is that when installing RVM I made sure that RVM was aware of Homebrew:

rvm autolibs enable
ram autolibs homebrew

The output from the install of ruby-2.3.3 is below:

Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.3.3.tar.bz2
Checking requirements for osx_brew.
Updating Homebrew...
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
ruby-2.3.3 - #configure
ruby-2.3.3 - #download
ruby-2.3.3 - #validate archive
ruby-2.3.3 - #extract
ruby-2.3.3 - #validate binary
Libraries missing for ruby-2.3.3: /Users/travis/.rvm/rubies/ruby-2.3.3/lib/libruby.2.3.0.dylib. Refer to your system manual for installing libraries
Mounting remote ruby failed with status 10, trying to compile.
Checking requirements for osx_brew.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/grantsayer/.rvm/rubies/ruby-2.3.3, this may take a while depending on your cpu(s)...
ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection...
ruby-2.3.3 - #extracting ruby-2.3.3 to /Users/grantsayer/.rvm/src/ruby-2.3.3

Next Steps

Currently I'm stuck - not been able to get past this step or validate through reviewing other postings to get a solution that works.

2
Can you show the commands you're using/used to install ruby-2.3.3 and rails? Just a hunch, but I wouldn't recommend installing rails through rvm. It's more reliable to install ruby through rvm, and then install rails through gem install rails --no-ri --no-rdocGlyoko
Try checking the status of the certs rvm is using: rvm osx-ssl-certs status all. This will output a status for each cert. If it is not Up to date, you can update them with rvm osx-ssl-certs update all.Joseph
Agree on using the gem for installing rails - which is what I typically do - probably not clear in the description.Grant Sayer
Checked on the certs rvm is using and running the command gave no output.Grant Sayer

2 Answers

18
votes

Well I found a solution to the problem previously described. The following steps outline how it was resolved.

CleanUp

  1. Removed the installation of Homebrew via ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

  2. Removed the installation of RVM via rvm implode

Rebuild

  1. Install Homebrew using ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Do integrity check on Brew using brew upgrade followed by brew doctor

  3. Install RVM (again!) using \curl -sSL https://get.rvm.io | bash -s stable
  4. Ensure that RVM knows about homebrew through the autolibs option using rvm autolibs homebrew
  5. Setup the environment variables so that we know where the openssl is installed:

    export LDFLAGS=-L/usr/local/opt/openssl/lib

    export CPPFLAGS=-I/usr/local/opt/openssl/include

    export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

  6. Install ruby via rvm install 2.3.3 --autolibs=homebrew

Check that it Works

  1. Check that the rvm space knows about the OpenSSL certificates using rvm osx-ssl-certs status all. Running this command produced the following output: Certificates for /usr/local/etc/openssl/cert.pem: Up to date.

  2. Install rails via gem install rails

At the last step the installation succeeded and Rails was working (at last!)

0
votes

If that doesn't work for another reader - try this:

rvm get branch /bugfix/3923_set_osx_brew_openssl_compiler_config
rvm install 2.4.0

If that works for you, go to the rvm issue and tell the developer how much you appreciate his effort :)