Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup RVM, Ruby on Mac OS X Sierra: Unable to require openssl

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

  • Mac OS X 10.12.3. (Sierra)
  • Homebrew 1.1.8. with OpenSSL installed
  • RVM 1.28.0
  • Ruby 2.3.3 Rails (attempting to install the latest)
  • Environment variables (following OpenSSL crate fails compilation on Mac OS X 10.11) the following variables have been setup in the Shell environment
  • LDFLAGS = -L/usr/local/opt/[email protected]/lib
  • CPPFLAGS = -I/usr/local/opt/[email protected]/include
  • PKG_CONFIG_PATH = /usr/local/opt/[email protected]/lib/pkgconfig

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.

like image 294
Grant Sayer Avatar asked Jan 30 '17 22:01

Grant Sayer


People also ask

Does RVM work on Mac?

The RVM install page has comprehensive instructions for installing RVM that work on Mac OS X. I'll provide the steps I used here. I've listed the mapis public key install command here for illustration. You should use the version on the RVM install page.

Can you install Ruby on Mac?

ruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby. ruby-build can also be used as a standalone program without rbenv. It is available for macOS, Linux, and other UNIX-like operating systems.


1 Answers

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!)

like image 87
Grant Sayer Avatar answered Oct 08 '22 01:10

Grant Sayer