You can have a .rvmrc
file in three different places:
/etc/rvmrc
sets options for the whole system;
~/.rvmrc
sets options for the current user;
.rvmrc
file in a specific directory customizes things for that project.
.rvmrc
files are mainly compile options for installing new Rubies.
However, the project-specific .rvmrc
files are the fun ones.
Here's how you do it:
.rvmrc
file in that directory.
rvm --rvmrc --create 1.8.6-p334This will create a heavily commented
.rmvrc
file that will change
your Ruby environment when you switch into that directory.
It gets even better with gemsets.
superproj
, I can do this:
rvm --rvmrc --create 1.9.2@superprojJust add an at-sign after the Ruby name and follow that with your gemset name.
Sigue un ejemplo. Creo un .rvmrc
en un directorio conteniendo el proyecto de un alumno:
[~/eleazar-src/prueba-activedirectory(testeo)]$ rvm --rvmrc --create 1.9.3-p392@eleazar-pfcVeamos la cabecera del
.rvmrc
:
[~/eleazar-src/prueba-activedirectory(testeo)]$ head -3 .rvmrc #!/usr/bin/env bash # This is an RVM Project .rvmrc file, used to automatically load the rubyAhora si entro en el directorio, la primera vez me lanza un warning:
[~/eleazar-src]$ rvm use 2.0.0-p0 Using /Users/casiano/.rvm/gems/ruby-2.0.0-p0 [~/eleazar-src]$ ruby -v ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin11.4.2] [~/eleazar-src]$ cd prueba-activedirectory/ You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers, you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version' * Do you wish to trust '/Users/casiano/eleazar-src/prueba-activedirectory/.rvmrc'? y[es], n[o], v[iew], c[ancel]> y -bash: /usr/bin/shasum: Permission denied [~/eleazar-src/prueba-activedirectory(testeo)]$ ruby -v ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin11.4.2] [~/eleazar-src/prueba-activedirectory(testeo)]$Para hacer que el mensaje de advertencia no aparezca:
$ rvm rvmrc warning ignore /Users/casiano/eleazar-src/prueba-activedirectory/.rvmrc Using /Users/casiano/.rvm/gems/ruby-2.0.0-p0 $ cd prueba-activedirectory/ -bash: /usr/bin/shasum: Permission denied $ ruby --version ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin11.4.2]
Véanse:
Casiano Rodriguez León 2015-01-07