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.
Written by Anthony Smith
Related protips
2 Responses
Thanks for the tip!
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.