Table of Contents
If you have questions about Ruby on Heroku, consider discussing it in the Ruby on Heroku forums.
Selecting a version of Ruby
You’ll need to install
1.2.0 of bundler to use the
See a complete list of supported Ruby versions
You can use the
ruby keyword in your app’s
Gemfile to specify a particular version of Ruby.
source "https://rubygems.org" ruby "1.9.3" # ...
When you commit and push to Heroku you’ll see that Ruby
1.9.3 is detected:
-----> Heroku receiving push -----> Ruby/Rack app detected -----> Using Ruby version: 1.9.3 -----> Installing dependencies using Bundler version 1.2.1 ...
For specifying non MRI ruby engines, you’ll need to use the
:engine_version options. You can specify JRuby by using the following line:
ruby "1.9.3", :engine => "jruby", :engine_version => "1.7.8"
Please see Ruby Support for a list of available versions.
If you were previously using
RUBY_VERSION to select a version of Ruby, please follow the instructions above to specify your desired version of Ruby using Bundler.
Specifying a Ruby version via the environment
Gemfiles are actually just Ruby code, so you can also specify your Ruby version in the environment. For example:
ruby ENV['CUSTOM_RUBY_VERSION'] || '2.0.0'
Would let you specify a Ruby version in the
CUSTOM_RUBY_VERSION environment variable, or default to 2.0.0 if it’s not set. This is handy if you are running your app through a continuous integration tool and want to ensure it checks your codebase against other versions of Ruby, but restrict it to a certain version when deployed to Heroku.
Changing environment variables does not recompile your app. For a Ruby version change to take effect through this method, you’ll need to deploy the app again since Ruby is vendored into each slug.
Applications that migrate to a non-default version of Ruby should have
bin be the first entry in their
PATH config var. This var’s current value can be determined using
$ heroku config -s | grep PATH PATH=vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
If absent or not the first entry, add
bin: to the config with
$ heroku config:set PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
PATH is set correctly you will see the expected version using
$ heroku run "ruby -v" Running `ruby -v` attached to terminal... up, run.1 ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
PATH is not setup correctly, you might see this error:
Your Ruby version is 1.9.2, but your Gemfile specified 1.9.3
If you’re using a Bundler
1.1.4 or lower you’ll see the following error:
undefined method `ruby' for #<Bundler::Dsl:0x0000000250acb0> (NoMethodError)
You’ll need to install bundler
1.2.0 or greater to use the
$ gem install bundler