I use rbenv but other team members use RVM.
When specifying the ruby 2.x.x version in the Gemfile I’ve been doing this:
ruby ENV['RBENV_VERSION'] || '2.2.4'
which grabs the current version I’m using from rbenv and uses it for the Gemfile. However, in production, it is not present and uses the specified version after ||.
I’ve been searching for a similar way to do this in RVM, the ultimate goal being to set up a Gemfile where all developers can use their local version of Ruby and a concrete version is specified for production.
This would allow developers to use rbenv or RVM for a project as well as not need to install new versions of Ruby every time they work on a project with a version they don’t have installed.
Are there any RVM users that can give me an equivalent to ENV['RBENV_VERSION'] for RVM? I’ve been searching a lot and haven’t found anything I like.
The best answer I can see is having RVM users specify the version via an environment variable name agreed upon by the team and used like "Specifying a Ruby version via the environment" as well and use that instead in the Gemfile.
2.2.4is only intended for production, and not development, why is this in yourGemfilein the first place? Why not put it somewhere more sensible, such asconfig/deploy.rb? - Tom Lordchruby? Or just a plain old system ruby? The only catch-all would be to specifyRUBY_VERSIONin the Gemfile, but that's explicitly what the Heroku docs say not to do! So instead, you could do something likeruby (ENV['DEVELOPMENT_MODE'] ? RUBY_VERSION : '2.2.4')... But now since we're setting an ENV variable flag, might as well just make it for the ruby version!ruby ENV['DEVELOPMENT_RUBY_VERSION'] || '2.2.4'..... Unless I'm missing something here? - Tom Lord