After upgrading to Catalina on my Mac, I realized that I was unable to install a new version of Ruby using RVM without encountering OpenSSL errors. This turned into a full fledged nightmare for a couple of clients’ source code who leverage old versions of Ruby.
If you’ve encountered issues with RVM, Ruby, Mac OSX, OpenSSL, nokogiri, V8, and therubyracer, and you only want to see the solution, click here.
This article assumes that you know to avoid using the version of Ruby bundled with Mac OS X. Instead, you should install your own version of Ruby with RVM, the Ruby Version Manager.
Prior versions of MacOS provided openssl-0.9.8 until the High Sierra release. Now, in MacOS 10.15.2, it’s LibreSSL. I have no idea why MacOS changed from OpenSSL to LibreSSL.
To see what eversion of OpenSSL is on your Mac, type the following command:
$ openssl version -a LibreSSL 2.8.3
To install the latest version of ruby-2.3.4, I take the following steps from the terminal prompt
$ rvm get master $ rvm cleanup all $ rvm install ruby-2.3.4 $ rvm use ruby-2.3.4 $ cd {app_folder} $ bundle install
First, I encountered problems installing nokogiri-1.8.4. The error logs stated.
conftest.c:3:10: fatal error: 'libxml/xmlversion.h' file not found #include <libxml/xmlversion.h> ^~~~~~~~~~~~~~~~~~~~~ 1 error generated.
After googling around, I uncovered that building nokogiri with the system libraries might be beneficial
gem install nokogiri -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
I then ran into issues with OpenSSL that prompted me to try
$ rvm pkg install openssl
The install openssl command failed with .rvm/log/1594962591/openssl_make.install.log,
/bin/sh: /Users/joelgarcia/.rvm/usr/ssl/man/man3/hmac.3: Too many levels of symbolic links
One blog post recommended that I remove the /.rvm/usr/ssl/man with rm -rf and try to run bundle install again to no avail.
Next, I searched online and found an article that recommended specifying the system OpenSSL libraries during the ruby installation to make use of the system openSSL.
I removed ruby-2.3.4 using
rvm remove ruby-2.3.4
I installed ruby-2.3.4 using
rvm install ruby-2.3.4 --with-openssl-dir='/usr/local/opt/openssl'
This looked promising until I started encountering problems with v8 and therubyracer. My gem install for therubyracer would always fail here, v$HOME/.rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.4/extensions/universal-darwin-19/2.6.0/therubyracer-0.12.3/mkmf.log, with an openSSL error.
Some more googling led me to the following link with the following code:
brew tap homebrew/versions brew install v8-315 gem install libv8 -v '3.16.14.13' -- --with-system-v8 gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 bundle install
Even after running this code, the bundle install would eventually fail with the inability to load openSSL.
Finally, I stumbled across the idea to install an older version of OpenSSL and to have the rvm install point to this older version of OpenSSL. Believe it or not this actually worked.
I installed the older version of OpenSSL with a tab by rbenv.
brew install rbenv/tap/[email protected]
Then I reinstalled ruby version referencing the old version of openssl. Success.
rvm reinstall 2.3.0 --with-openssl-dir='/usr/local/opt/[email protected]'