How can I choose Ruby version on Heroku?
Asked Answered
S

3

20

I use Ruby 1.9.x syntax in my Rails 3 app, but after pushing it to Heroku it crashes due to older Ruby version (1.8). How can I control it?

Sepulchral answered 31/8, 2010 at 23:29 Comment(1)
You can now specify what version of ruby you wish to run on Cedar too: blog.heroku.com/archives/2012/5/9/…Lawrenson
T
34

Heroku's current stack, Cedar, uses 1.9.2 by default. Cedar also supports specifying the Ruby version in your Gemfile. Currently, 1.9.2 and 1.9.3 are valid options.

# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
...

More details are available in the Ruby support article: https://devcenter.heroku.com/articles/ruby-support


If you are currently using Aspen or Bamboo, you can switch to 1.9.2 by using the stack:migrate command:

$ heroku stack:migrate bamboo-mri-1.9.2

You cannot automatically migrate to the Cedar stack at this time, but there is a guide on how to do so: https://devcenter.heroku.com/articles/cedar-migration

Timeworn answered 31/8, 2010 at 23:43 Comment(0)
L
4

You can now explicitly specify a Ruby version on Heroku.

Simply setup your Gemfile as so

# Gemfile
source "https://rubygems.org"
ruby "1.9.3"

# Gems go here
Loriloria answered 25/5, 2012 at 17:49 Comment(0)
C
0

I wanted to use the version I already had defined in the .ruby-version file so I ended up creating a buildpack that can be used before heroku-buildpack-ruby that injects the version from the .ruby-version into the Gemfile. It also support versions without patch or aliases.

https://github.com/platanus/heroku-buildpack-ruby-version

This way you can have your version defined only in one place.

Channelize answered 30/1, 2016 at 5:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.