Moving to ruby-2.0.0-p0 on Mac+RVM and Ubuntu 12.04
StatusPage.io is now running Ruby 2.0 in production. Making the switch wasn't very difficult, but there were definitely a couple gotchas. Below is a documented version of our switchover on Mac+RVM and Ubuntu 12.04 LTS compiling from source.
Mac + RVM
We use RVM to manage our ruby version installs because we are often maintaining up to 4 versions and gemsets at any given time between StatusPage.io and our contract work. Please don't harangue me for not using rbenv. Let's check out some dependencies and then we'll do the install.
Homebrew for openssl and readline
The version of openssl that ships with Mac OS X is incompatible with ruby-2.0.0-p0, and the ruby install will annoyingly just skip quietly over this compatibility. We ran into this on our initial
bundle install, and it took a while to track down why 1.9.3 didn't have this issue. Let's get a new version of openssl, and we'll grab readline as well while we're at it (methinks so debugger operations will work correctly with the debugger gem).
brew install openssl readline
Do the actual install with RVM
RVM requires you to be completely explicit with installing Ruby 2, likely because of a name conflict with something like a JRuby or Rubinius. Earlier versions let you just do something like 1.9.3, but now we're forced to use the full ruby-2.0.0-p0. We'll also specify the newly installed openssl and readline as directories to accompany the install.
rvm install ruby-2.0.0-p0 --with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`
Edge Bundler and Gemfile specs
Let's make sure we're using the edge version of bundler so that we can take advantage of the ruby directive, and we'll ensure that we're using the https version of rubygems so that we can't get hit with a MITM attack.
gem install bundler --pre
We hit a couple random issues with gems that we had installed long ago. You may experience the same, and I recommend checking out the latest version of the gem to see if it makes the gremlins go away.
gem 'rest-client', '~> 1.6.7'
gem 'binding_of_caller', '~> 0.7.1'
Ubuntu LTS 12.04 and Chef
We use a custom Chef cookbook to manage installing ruby on our production systems by compiling from source. Changing the system ruby when you depend on Chef is always a bootstrappy web of emotion and anti-gravity, and moving to Ruby 2 was even more scary given how many dependencies are assumed on Chef's end. We only ended up hitting one snag, and luckily somebody over at Opscode had already merged a change for this.
Long story short, we modified the chef-ruby-src repo to build and install a custom chef gem that had this patch already committed.
For those of you not using Chef, below is a small bash script that will just get you ruby-2.0.0-p0 installed.
Just to recap, we use chef to build a new system ruby and install a new chef gem under itself. Take that, grandfather paradox!
We push a lot of code, and although the unicorn setup we have allows for hot reloads there can be times when we have to pause traffic with HAproxy and do a hard restart of the unicorns. Cutting ~40% off of the startup time is significant, and this feature alone was enough of a driver to get us to upgrade.
Suggestions and Corrections
Please email firstname.lastname@example.org with any suggestions or corrections for this article.