mpapis, rys, ddd on IRC in
#rvm on irc.freenode.net
RVM supports multiple types of files to allow configuring 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,
.ruby-version- single line
.rvmrcwill work in all RVM versions; the other files were introduced in RVM
This is the first supported format and it has precedence over any other files.
.rvmrc has one major flaw - it requires trusting to prevent execution of unauthorized code,
which makes it hard to use and complicates deployment to production.
In cases where scripting is not required, use of other project files is encouraged.
Generating a simple
echo 'rvm --create use ree@tedxperth' > .rvmrc
A more complex version:
rvm --create use ree@tedxperth --rvmrc
The file can be edited to provide extra customizations.
To trust the file:
rvm rvmrc trust /path/to/project
echo 1.9.3 > .ruby-version # OR: rvm --ruby-version use 1.9.3
When in RVM,
.ruby-version also supports gemsets in the form of
but this is not compatible with other Ruby Versions Managers.
Another file might be used to specify the gemset without breaking compatibility -
echo my_app > .ruby-gemset # OR: rvm --ruby-version use 1.9.3@my_app
The second form will create both
Some projects require extra configuration in environment; this is supported by using the
echo "JRUBY_OPTS=--1.9" >> .ruby-env
This variable will be set when entering the project directory and reverted to its previous value when exiting the project directory.
Note that the following files are also supported:
They have lower precedence than
For more advanced projects
.versions.conf is supported, where more than the ruby version can be specified.
rvm --create --versions-conf use 1.9.3@my_app
ruby=jruby-1.6.8 ruby-gemset=my_app env-JRUBY_OPTS=--1.9
ruby directive is supported and will be read by RVM.
ruby "1.9.3" gem "haml"
In case it is not possible to use the
ruby directive or when a more fine-grained
version is required, the following comments will take precedence over the directive:
#ruby=jruby-1.6.8 #ruby-gemset=my_app #ruby-env-JRUBY_OPTS=--1.9
Another example, using MRI Ruby at a specific patch level:
Comments are preferred as older versions of
bundler did not support the directive.
Those variables can be set in
rvm_project_rvmrc_default=1- Prefer default ruby when project file not found in current directory,
bundlergem and run