Pages

Search This Blog

March 10, 2014

Still using .rvmrc??

.rvmrc is a shell script that allows for full customization of the environment for the Ruby project in subject.If you've got a whole bunch of nix shell scripts in that file for some customizations in the environment, then I sympathise your state and am afraid that this post might not serve much purpose to you.

Do read further if your sole aim is to switch Ruby versions and the content of your .rvmrc file is something like below (which usually is the case).

#ruby_version@gemset_name
1.9.3p484@bdd

It is time to migrate your .rvmrc file to .ruby-version and .ruby-gemset. The .rvmrc file is deprecated in favour of the files - .ruby-version and .ruby-gemset. This change is for the reasons below:

.rvmrc file execution requires trusting to prevent execution of unauthorized code. This complicates automated deployment at different environments, esp. production deployment when you got to change the ruby versioning. It is advised to run ``rvm rvmrc trust /path/to/project`` to trust the .rvmrc file.

The files .ruby-version and .ruby-gemset is supported by many ruby version managers including the popular rvm and rbenv.

Generating .ruby-version file (say, to use ruby version 1.9.3-p484):$ rvm --ruby-version use 1.9.3-p484

Generating .ruby-gemset file (say, to use gemset by name rails3)$ rvm --ruby-version use 1.9.3-p484@rails3

Note:

Make sure to remove your .rvmrc file as it takes precedence over other configuration files in the rvm environment

The .ruby-gemset file works in conjunction with the .ruby-version file and does not work alone.

And when you are using gemset as well use both the said files and do not include gemset information in .ruby-version file to cross framework compatibility.