Last Updated: February 25, 2016
·
1.272K
· Marko Klemetti

Creating and overriding .rvmrc

If you don't know what is RVM, check it out.

Setting your project environment with rvmrc

rvmrc is a file which together with RVM makes sure you are always running the correct ruby version and gems for your application. You can set a project-specific environment with a file called .rvmrc by running the following command in your project root:

$ rvm --rvmrc --create jruby-1.7.0@mygemset

Now as you enter your project-folder, RVM automatically selects jruby-1.7.0 and uses the rubygems installed in the gemset mygemset.

Simpler rvmrc file

Since RVM creates a slightly bloated .rvmrc, you can also create the same environment file by manually writing it:

$ echo "rvm use jruby-1.7.0@mygemset" > .rvmrc

It is much cleaner and simpler to understand.

Overriding rvmrc

You probably never have to override your rvmrc. However I have an application which is using JRuby and I deploy it using Capistrano. Unfortunately JRuby doesn't properly support Capistrano and I have to deploy the application by running:

$ rvm ruby-1.9.3-p327 do cap deploy

It selects another ruby version (ruby 1.9.3) for the one command only. And if you want, you can naturally create a rake task or a shell alias for running the command for you.