Can chruby and chgems replace rvm's gemset?
Asked Answered
F

1

9

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?

Filth answered 17/6, 2013 at 14:57 Comment(0)
R
10

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.

Ritualist answered 17/6, 2013 at 19:1 Comment(3)
Updated my answer on June 24 to reflect changes resulting from the release of Chruby 0.3.6.Ritualist
one can also use github.com/tonchis/gst it works better with chruby than chgemsSpendable
Worth nothing: chgems has been deprecated in favor of gem_home.Ritualist

© 2022 - 2024 — McMap. All rights reserved.