Ruby 1.9.3-p551 in MacOS

Mark Lin
LifeOps — One problem at a time.
1 min readDec 10, 2021
Photo by Joshua Fuller on Unsplash

Have old ruby code that needs modification in 2021? One could use docker to build the exact same environment as 2011, but it’s not as nice as editing the code and seeing rails console reload instantly.

After much frustration and bless of Buddha, we nail down the steps needed to compile ruby-1.9.3 on Monterey with xcode and its command line tools.

# Install RVM
\curl -sSL https://get.rvm.io | bash
# This env variable is needed to compile ruby 1.93 successfully. See: https://stackoverflow.com/questions/69298869/what-does-with-cflags-wno-error-implicit-function-declaration-doexport CFLAGS=-Wno-error=implicit-function-declaration# Ruby 1.9.3 needs openssl 1.0
brew install rbenv/tap/openssl@1.0
# Latest version of rubygems that supports ruby 1.9
rvm_rubygems_version=2.7.9 rvm reinstall ruby-1.9.3 --with-openssl-dir=/usr/local/opt/openssl@1.0
# If you use rails app
brew install v8@3.15
brew link v8@3.15
# Install these 2 gems individually
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8\@3.15/
# Run this in your app directory to install needed gems.
bundle install

This is tested on MacOS Monterey 12.0.1 with Xcode 13.1.

Best luck to those of you needing to modify old codes. I guess one can replace rvm with rbenv, just replace rvm install command appropriately.

--

--