Last Updated: February 25, 2016
·
7.687K
· anthonator

Specify Ruby version in Gemfile

Does your app need to set a dependency on your Ruby version? Want to make sure the Ruby versions on your development and production servers are the same? Want your app to fail faster if the wrong version of Ruby is installed? Just specify what version you want to use in your gemfile using the ruby directive.

ruby "<ruby version>",
  :engine => "<ruby implementation>",
  :engine_version => "<ruby implementation version>"

For example, if you wanted to use Ruby 1.9.3 powered by JRuby you can do the following:

ruby "1.9.3",
  :engine => "jruby",
  :engine_version => "1.6.7"

Note: The ruby directive explicitly leaves out the ability to specify a patch level. Ruby patches often include important bug and security fixes and are extremely compatible.

http://gembundler.com/v1.2/gemfile_ruby.html

2 Responses
Add your response

Thanks for the tip!

over 1 year ago ·

I'd like to add that you need bundler 1.2 or higher for this to work. Also, it works different from other gems in that it won't automatically install or upgrade your app to newer versions of ruby (i.e. if you specify ruby 2.0.0), it will simply throw an error when you run bundler to notify you that the ruby version installed on your system differs from the one specified in the gemfile.

over 1 year ago ·