From: Phillip Gawlowski Date: 2009-12-26T05:26:36+09:00 Subject: Re: question about multiple ruby + gems installations for dev/test/prod On 25.12.2009 20:31, Alex Rice wrote: > Hi All, I am pretty new to Ruby, and googled quite a bit about the gem > utility, but am kind of stuck. I need some advice about maintaining good > separation between ruby installs and gem directories. http://rvm.beginrescueend.com/ Seems like that's what RVM was intended for. :) > In this project we have Ruby installs for dev, test and prod. The idea > is we can test different versions of ruby, rails, and different gems. > Then when it's getting promoted from test to prod, just cp -R the ruby > directory and all it's gems from test to prod. Nice idea except the gems > paths are all fouled up now. > > Question: How does the gem script actually figure out it's environment > and where it's gems are? Is there a config file somewhere? I can't find > it if there is. While I'm not aware of Rubygem's internals, I know that it does look at ".gemrc" in the home directory of a user first, to parse variables, including GEM_HOME and GEM_PATH. Coupled with RVM, this should enable you to separate your dev/test/prod environments on the same machine. > I am aware of the GEM_PATH and GEM_HOME environment variables. They are > not currently set. I have lots of shell scripts pointing at this ruby > install, and don't want to have to add GEM_PATH and GEM_HOME to all of > those shells scripts. However if that's the only way, then I guess I can > live with that. See ".gemrc" in Rubygem's manual: http://docs.rubygems.org/read/chapter/11 That should enable you to setup a .gemrc-dev, a .gemrc-testing, and a .gemrc-production with ease. Alternatively, you could also use rake rails:gem:freeze to, well, freeze the gems your Rails app uses. -- Phillip Gawlowski Wishing everyone a Merry Christmas, and happy holidays :)