Reputation: 710
I'd like to use a specific version of ruby when running my app in production on Heroku.
As explained here, you only have to add a line like ruby "2.0.0"
in your Gemfile.
However, as I use RVM locally, I already specified the ruby version to use in a .ruby-version
file in the root directory of the project that only contains the line ruby-2.0.0-p0
.
To avoid code duplication, I'd like the version to be specified in only one place, so that I'm sure that the same version is always used in development and on Heroku.
Is there a way to do that ?
Upvotes: 3
Views: 375
Reputation: 538
The Gemfile
is ruby code, so you can write some ruby to read the version from .ruby-version
and pass that value to the ruby
method, rather than a hard-coded version string.
If the .ruby-version
file is in the same directory, something like this should work:
ruby File.read(".ruby-version").strip.split("-").first
If the .ruby-version
file contains "1.9.3-p327", for example, that line would be equivalent to:
ruby "1.9.3"
Upvotes: 6
Reputation: 37507
No, you can't specify the patch level to be used on Heroku - they manage patch levels for you. You need to track their changelog to know when patch levels change. So you need to make sure you are using the same patch level locally which for Ruby 2.0.0 it's present p195.
Upvotes: 0