Shortcut for selecting RVM gemset

I developed a couple of applications with RoR 3.0.3 and 2.8.4, which means that I often go back and forth between RVM resources. My 3.0.3 RVM is called ruby-1.9.2-p0@ror3 and the other is ruby-1.8.7-p0@ror2 . Is there a faster way to switch b / w two other than rvm use ruby-1.9.2-p0@ror3 and rvm use ruby-1.8.7-p0@ror2 ?

+6
source share
1 answer

Is there a faster way to switch b / w two other than rvm, use ruby-1.9.2-p0@ror3 and rvm use ruby-1.8.7-p0@ror2 ?

This is the exact reason I created the .rvmrc project files for each project. The fundamental concept of RVM is that it should manage your environment for you as soon as you have all the settings and don't go out of the way. Therefore, please read about the .rvmrc files for each project and add them to your workflow.

First, create two new project catalogs,

 $ mkdir ~/project1 ~/project2 

Now we generate .rvmrc files for each project for each project,

 $ cd ~/project1 $ rvm --rvmrc --create 1.8.7@ror2 $ cd ~/project2 $ rvm --rvmrc --create 1.9.2@ror3 

To demonstrate this, go back to the home directory and select the ruby ​​system,

 $ cd ~/ $ rvm system $ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] 

We see here that in this case we have a ruby ​​system installed as 1.8.7-p174 (OSX).

Now, if I change directories in project1,

 $ cd ~/project1 $ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.6.0] $ gem env home /Users/wayneeseguin/.rvm/gems/ ruby-1.8.7-p334@ror2 

We see that we are using RVM 1.8.7-p334 with gemset ror2

Now, if we change directories to project2,

 $ cd ~/project2 $ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0] $ gem env home /Users/wayneeseguin/.rvm/gems/ ruby-1.9.2-p180@ror3 

We see that now we are using 1.9.2-p180 with gemset ror3, and we did not have to manually select it :)

This is my best effort to date to keep the RVM away from your path and still help you in your workflow. I hope you find this helpful and enjoy!

You can read about the use of .rvmrc files for each project on the RVM documentation website.

~ Wayne

+13
source

Source: https://habr.com/ru/post/885442/


All Articles