4

The RVM Best Practices state that, to connect a project to a specific Ruby version, you should specify that version in the project-specific rvmrc file.

This SO answer states that, in most situations, you should use specify the Ruby version in the .ruby-version file.

Heroku says you should specify the Ruby version in Gemfile.

What is the correct way to specify a Ruby version, using RVM, if the app will be deployed on Heroku?

Community
  • 1
  • 1
ben
  • 29,229
  • 42
  • 124
  • 179

3 Answers3

4

.rvmrc is deprecated and you should use .ruby-version instead.

But Heroku does not pay attention to the .ruby-version. Heroku wants to have it in the Gemfile. So I think you should use both: .ruby-version (for you) and Gemfile (for Heroku).

spickermann
  • 100,941
  • 9
  • 101
  • 131
  • `.rvmrc` is not deprecated - that word is not used in the message, the message is to make you aware, it does not state that `.rvmrc` will no more be used – mpapis Sep 13 '13 at 22:14
2

You need to place it in the Gemfile for Heroku's sake, but if you're using a version manager, then you'll need to use something else for the sake of the version manager. I think the SO answer makes sense in that regard (i.e. the .ruby-version file).

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
1

Check https://rvm.io/workflow/projects - it says you can use Gemfile to specify ruby version for RVM like this:

ruby "1.9.3"

or something more complicated:

ruby File.readlines(".ruby-version").first.strip

and then in .ruby-version:

1.9.3

this way it will work also with other ruby environment managers like chruby

mpapis
  • 52,729
  • 14
  • 121
  • 158