Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top