I've been dev'ing a couple apps with RoR 3.0.3 and 2.8.4, which means I have to bounce back and forth between the RVM envirnoments quite frequently. My 3.0.3 RVM is called ruby-1.9.2-p0@ror3
, while the other is ruby-1.8.7-p0@ror2
. Is there a faster way to switch b/w the two other than rvm use ruby-1.9.2-p0@ror3
and rvm u开发者_开发技巧se ruby-1.8.7-p0@ror2
?
Is there a faster way to switch b/w the 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 that I created per-project .rvmrc files. The fundamental concept behind RVM is that it should manage your environment for you once you have everything setup and stay out of your way. So please read about the per-project .rvmrc files and add them into your workflow.
First let us create two new project directories,
$ mkdir ~/project1 ~/project2
Now we generate per-project .rvmrc files for each project,
$ cd ~/project1
$ rvm --rvmrc --create 1.8.7@ror2
$ cd ~/project2
$ rvm --rvmrc --create 1.9.2@ror3
In order to demonstrate this let us go back to the home directory and select system ruby,
$ 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 system ruby installed as 1.8.7-p174 (OSX).
Now if I change directories into 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's 1.8.7-p334 with gemset ror2
Now if we change directories into 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 we are now using 1.9.2-p180 with gemset ror3 and we did not have to manually select it :)
This is my best effort to date for having RVM stay out of your way and yet assist you in with your workflow. I hope that you find it useful and enjoy it!
You can read about using per-project .rvmrc files on the RVM documentation website.
~Wayne
精彩评论