[Mongrel] Auto-installing Gems via boot.rb causes errors under Mongrel

Chad Woolley thewoolleyman at gmail.com
Wed Feb 7 02:00:29 EST 2007


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


More information about the Mongrel-users mailing list