How can I use RVM to set a default ruby version for a certain directory? So that every time I cd
into that directory, it switches to my preferred version of Ruby.
Directly from the RVM documentation:
RVM supports multiple files allowing to configure a project for automated ruby switching. In any case make sure to add those files to your version control systems as it is part of the project configuration.
Listed in order of precedence:
- .rvmrc - shell script allowing full customization of the environment,
- .versions.conf - key=value configuration file
- .ruby-version - single line ruby-version only
- Gemfile" - comment: #ruby=1.9.3 and directive: ruby "1.9.3"
One way is to use a Gemfile
and set the ruby version in it. like so:
ruby '2.2.0'
then when you enter the directory you will see the following message from rvm
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /Users/danmanstx/rails_projects/app/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With