문제

I am currently using rvm on my development machine for switch between rubies (mainly 1.9.x and 1.8.7). Then I came across chruby and found the "Does not hook cd" feature attractive.

Can chruby + chgems replace rmv's gemset feature?

Before:

$ rvm 1.8.7

will switch to ruby 1.8.7 with the 1.8.7 set of gems for my older rails projects. And:

$ rvm 1.9.3

will switch to ruby 1.9.3 with the 1.9.3 set of gems for my new rails projects.

How can that be achived by chruby and chgems?

도움이 되었습니까?

해결책

I'll take a run at this question since I use Chruby and Chgems. I am on Mac OS X, and I have chruby installed via Homebrew.

In my .bashrc file:

source /usr/local/share/chruby/chruby.sh
chruby ruby-2.0.0-p195

The source line is part of configuration for Chruby.

The second line sets a default version of Ruby for my system (in my case Ruby 2.0.0). Note: As of Chruby 0.3.6 this belongs in .bashrc instead of .bash_profile.

In my .bash_profile:

source /usr/local/share/chruby/auto.sh

This line sets Auto-switching feature in Chruby.

I still have some projects using Ruby 1.9.3 so for those apps I have a .ruby-version file in the root of the app. with one line ruby-1.9.3


When you cd into the directory for your app, type chgems and then you can bundle install and what not. You can confirm things are working by entering gem env

To make my life easier I added .bash_aliases for example: alias myapp='cd ~/Sites/myapp && chgems'


I have been using these together for several months now and really like the combination and yes from what I can tell Chgems does a great job replicating the gemset feature of RVM. I highly recommend you read the docs for both Chruby and Chgems projects as this is all covered. In your case, you may not want to set a default Ruby and just use .ruby-version to set it for each app.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top