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
MORE ARTICLES LIKE THIS: