Search code examples
rubymacosunixdirectoryrvm

Set a default Ruby version for a specific directory (RVM)


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.


Solution

  • 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'.