Hello, I''m trying to augment the GEM_PATH to load gems from ~/.gem/ using this at the begging of the rails application config/environment.rb file: ENV[''GEM_PATH''] = File.expand_path(''~/.gem'') This works fine from within script/console: $ script/console>> require ''pdf/writer''=> true But when I try to run: mongrel_rails cluster::start It fails to load the local gem. I started to dig into the code, and realized that rubygems is initialized by mongrel_rails before it loads the environment.rb file, which results in GEM_PATH env. variable being "ignored" (because rubygem Gem.path method caches the path on the first use, which is done by mongrel_rails). To make this work, I had come to this hack: ENV[''GEM_PATH''] = File.expand_path(''~/.gem'') require ''rubygems''; Gem.clear_paths; Gem.instance_variable_set(:@searcher, nil) Which clears the internal cache used by rubygems, and forces it to re-read the GEM_PATH env. variable. But I don''t fell comfortable using it... is there a better way to do this? Like, setting the GEM_PATH from the mongrel cluster config file? Best regards, Rui Lopes PS: require ''rubygems'' is needed just in case we run script/console from console.
Zed A. Shaw
2007-Feb-16 09:55 UTC
[Mongrel] mongrel cluster and local gems loading problem
On Thu, 08 Feb 2007 14:53:44 +0000 Rui Lopes <rgl at ruilopes.com> wrote:> Hello, > > I''m trying to augment the GEM_PATH to load gems from ~/.gem/ using this > at the begging of the rails application config/environment.rb file: > > ENV[''GEM_PATH''] = File.expand_path(''~/.gem'')Hey Rui, I know you were chatting with me on IRC about this. Did you ever find a solution? -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://www.awprofessional.com/title/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Seemingly Similar Threads
- Version Control (and gems)
- Cannot find gem for Rails error from dispatch.cgi
- Issue with Deploying a Rails app on VPS - cannot load such file -- unicorn/launcher
- Camping-list Digest, Vol 15, Issue 2
- Auto-installing Gems via boot.rb causes errors under Mongrel