Alan Morales

March 29, 2021

How to build RVM Rubies(< 2.4) with OpenSSL 1.0.2 on a M1 Apple MacBook Pro

I wanted to bring back to life one of my Ruby side projects, unfortunately it depends on OpenSSL 1.0. I found guides all over the internet on how to compile it on an Intel processor (x86_64), but since version 1.0.x is no longer supported (meaning as of December 31st, 2019 it no longer receives fixes of any sort) I had to figure out a way to make it work on my shiny new M1 MacBook Pro.

Thankfully, the Internet came to the rescue, all I had to do was stitch together a few guides / Github fixes I read and install my version via homebrew. Here are the broken down steps

Prequisites
  • Xcode and the Xcode command line tools (Xcode has to be installed under the Applications folder)
  • Homebrew


Install my modified OpenSSL 1.0.2 Homebrew tap in your computer
brew tap corvuszero/openssl-apple-m1_1_0_2
brew install openssl-apple-m1_1_0_2


Figure out the path where OpenSSL lives in your computer
brew --prefix openssl@1.0

For M1 it should be something similar to /opt/homebrew/opt/openssl@1.0.2tDouble check on your own computer beforehand!


Install the Ruby version you want specifying the OpenSSL version we just compiled with homebrew
Fiddle is another issue with RVM on Apple M1. That option is a workaround as well
PKG_CONFIG_PATH=/opt/homebrew/opt/openssl@1.0.2t/lib/pkgconfig rvm install YOUR-RUBY-VERSION --with-openssl-lib=/opt/homebrew/opt/openssl@1.0.2t/lib --with-openssl-include=/opt/homebrew/opt/openssl@1.0.2t/include --with-out-ext=fiddle


If everything went well, you should be able to use your recently compiled Ruby, install bundler and keep going!


References

This solution "just works" for now, it is NOT intended for production use, but I hope it gets you further.

Alan

About Alan Morales

www.alanthoughts.gov/www\alanthoughts. Check it out