Archive RSS Email

The Rails Tutorial and Heroku Cedar-14

Nov 4, 2014 • posted by Michael Hartl

UPDATE: Due to continuing annoyance, I’ve determined that, in the case of the Rails Tutorial, the costs of specifying a particular version of Ruby in the Gemfile don’t justify the benefits. The Ruby on Rails Tutorial book has been updated accordingly. As a result, there is no need to follow the steps below to install a new version of Ruby.

This is a quick update for users of the 3rd Edition of the Ruby on Rails Tutorial , especially those deploying to Heroku from the Cloud9 IDE, but it’s potentially useful to anyone deploying Ruby apps to Heroku. Heroku’s recently announced Cedar-14 stack is incompatible with all but the most recent version of each Ruby sequence, meaning (for example) that it works with Ruby 2.1.4 but not with 2.1.3. Unfortunately, this makes it incompatible with the local Ruby versions on many systems, including Cloud9’s default, which as of this writing is Ruby 2.1.1. In such cases, Heroku deployments to the new stack won’t work. Here are the kinds of errors you might see:

local/Cloud9 => Your Ruby version is 2.1.1, but your Gemfile specified 2.1.4

Heroku => Only the most recent version of Ruby 2.1 is supported on Cedar-14

For the benefit of Rails Tutorial readers, I’ve gotten in touch with Cloud9 support and expect that they will eventually be able to change the default Ruby version for Rails Tutorial workspaces. UPDATE: This has now happened, so new workspaces will get Ruby 2.1.4 automatically, but existing workspaces will still have to be updated manually. You can do this with the Ruby Version Manager as follows:

$ rvm install 2.1.4
<get a beverage of your choice and wait a while>
$ rvm use 2.1.4

Then change your Gemfile to use the line ruby '2.1.4' and re-deploy:

<update Gemfile>
$ git commit -am "Update Ruby version"
$ git push heroku

You may also have to restart any Rails servers, consoles, or Spring servers (spring stop) in order to get them to use the new version of Ruby.

By the way, if you’re using rbenv on a local machine (as I am) and need to upgrade to the latest Ruby version, here are the steps you might follow:

$ cd ~/.rbenv/plugins/ruby-build/
$ git pull
$ rbenv install 2.1.4
Michael Hartl

I’m Michael Hartl—author, educator, and entrepreneur. I’m probably best known as the creator of the Ruby on Rails Tutorial, a book and screencast series that together constitute one of the leading introductions to web development. Once called his “favorite book” by Wikipedia founder Jimmy Wales, the Ruby on Rails Tutorial currently has over 150 5-star reviews at Amazon. I’m also (in)famous for creating Tau Day and The Tau Manifesto, which have inspired an international movement dedicated to the proposition that “pi is wrong.” (For example, as a result of The Tau Manifesto, MIT releases their admissions decisions each year at “Tau Time” (6:28 p.m.), and typing tau/2 at Google yields 3.14159…) Finally, I’m a founder of Softcover, a publishing system and sales platform for technical authors, which among other things powers both The Tau Manifesto and the Ruby on Rails Tutorial.

I’m a graduate of Harvard College and have a Ph.D. in Physics from Caltech, where I studied black hole dynamics and was an award-winning instructor in theoretical and computational physics. I’m also an alumnus of Y Combinator, the entrepreneur program that has produced companies such as Dropbox and Airbnb. (Alas, my own Y Combinator startup was neither Dropbox nor Airbnb.)