Ruby Version Manager quick tips
I have been using Ruby Version Manager (RVM) for over a year and I think it is a great tool that makes life easier for me as a ruby developer. It wasn’t until recently that I started to checkout the different configuration options for it.
Configuration
RVM uses a file called .rvmrc
in your home directory for global configuration. If you need system wide configuration your can use /etc/rvmrc
. The .rvmrc in your home directory will overwrite the settings in /etc/rvmrc if both exists.
My .rvmrc
looks like this
When rvm_gemset_create_on_use_flag
is set to 1
RVM will automatically create a gemset if you cd into a directory with a .rvmrc file that specifies a gemset that doesn’t exist. This is good for skipping those ERROR: Gemset 'the-app' does not exist ...
errors.
The rvm_install_on_use_flag
will make it so RVM automatically install new rubies if it encounters a project .rvmrc that specifies a ruby that isn’t already installed on the system.
You can also set export rvm_trust_rvmrcs_flag=1
to skip the prompt about trusting a project .rvmrc file that is displayed when RVM encounters a .rvmrc file that it hasn’t seen before on the system. However I keep that setting off because I think it is good to get a notice when you cd into a directory that has .rvmrc file the first time.
More configuration options
The RVM install includes a file with examples of the different configuration settings you can use in ~/.rvm/example/rvmrc
. Also check out the documentation on rvmrc files.
Default gems for gemsets
RVM creates a gemset called global
for each ruby version you install. This gemset will be used as the base for all newly created gemsets. It is pretty sweet to ensure that you always have bundler and rake available in new gemsets: