Chad Woolley
2007-Feb-07 07:00 UTC
[Mongrel] Auto-installing Gems via boot.rb causes errors under Mongrel
Hi, I''m trying to make my Rails app auto-install my required gems, by invoking the gem installation in boot.rb. I''ll use the ActionMailer gem as an example: ... system "sudo gem install actionmailer --version=1.2.5 -y" ... Problem is that this fails on the first invocation of Mongrel - it can''t find the gem. However, if I kill and restart mongrel (with the gem now installed), it works fine. This problem does NOT occur with webrick, but webrick appears to parse boot.rb twice when it is started. Also, if I invoke the rubygems API programatically, not via system, this problem doesn''t occur - but I can''t use sudo with this approach. Any ideas why this happens, or how to work around it? Below is the output of what happens, from mongrel and webrick. Thanks, Chad ------------ $ sudo gem uninstall actionmailer -i Successfully uninstalled actionmailer version 1.2.5 $ mongrel_rails start ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Successfully installed actionmailer-1.2.5 Installing ri documentation for actionmailer-1.2.5... Installing RDoc documentation for actionmailer-1.2.5... /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:251:in `report_activate_error'': Could not find RubyGem actionmailer (= 1.2.5) (Gem::LoadError) from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:188:in `activate'' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:213:in `each'' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:213:in `activate'' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:66:in `active_gem_with_options'' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:59:in `require_gem'' from /Users/woolley/workspace/geminstaller/spec/sample_rails_app/config/boot.rb:39 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' ... 13 levels... from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243 from /usr/local/bin/mongrel_rails:18:in `load'' from /usr/local/bin/mongrel_rails:18 $ mongrel_rails start ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Successfully installed actionmailer-1.2.5 Installing ri documentation for actionmailer-1.2.5... Installing RDoc documentation for actionmailer-1.2.5... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel available at 0.0.0.0:3000 ** Use CTRL-C to stop. $ sudo gem uninstall actionmailer -i Successfully uninstalled actionmailer version 1.2.5 $ ruby script/server Successfully installed actionmailer-1.2.5 Installing ri documentation for actionmailer-1.2.5... Installing RDoc documentation for actionmailer-1.2.5... => Booting WEBrick... Successfully installed actionmailer-1.2.5 Installing ri documentation for actionmailer-1.2.5... Installing RDoc documentation for actionmailer-1.2.5... => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2007-02-06 23:53:27] INFO WEBrick 1.3.1 [2007-02-06 23:53:27] INFO ruby 1.8.5 (2006-08-25) [i686-darwin8.7.1] [2007-02-06 23:53:27] INFO WEBrick::HTTPServer#start: pid=1385 port=3000
Zed A. Shaw
2007-Feb-16 10:02 UTC
[Mongrel] Auto-installing Gems via boot.rb causes errors under Mongrel
On Wed, 7 Feb 2007 00:00:29 -0700 "Chad Woolley" <thewoolleyman at gmail.com> wrote:> Hi, > > I''m trying to make my Rails app auto-install my required gems, by > invoking the gem installation in boot.rb. I''ll use the ActionMailer > gem as an example:Did you ever figure this out Chad? My thinking is that if there''s anything messing up gems it''d be GemPlugins. The easiest way to test that is open up mongrel_rails, go to the bottom where GemPlugin is run, and then put that into the webrick script real quick. If that then blows up webrick then that''s the cause. Otherwise, it might be some kind of race condition that isn''t hit because webrick is slower. -- 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.
Reasonably Related Threads
- Error with mongrel_rails start
- mongrel startup fails now: already initialized constant OPTIONS
- mongrel on linux error - custom_require.rb:27:in `gem_original_require'': no such file to load -- (LoadErro
- Mongrel 1.1.1 Win32 (latest) + Rubygems
- mongrel cluster issues, plain old mongrel OK