DrbServer incompatible with config.gem

I recently upgraded to Rails 2.2.2 and refactored some of my rails code
to use the config.gem functionality. In doing so, I noticed some odd
behavior when trying to start the DrbServer. Essentially, the DrbServer
will not start unless I have the “require 'acts_as_ferret” statement
below in environment.rb. I thought the gem.config would have been
enough, but apparently not.

– start environment.rb –

Rails::Initializer.run do |config|

[…]

Requires acts_as_ferret must be here, can’t figure out why

require ‘acts_as_ferret’

config.gem ‘acts_as_ferret’, :version => ‘0.4.3’
config.gem ‘ferret’, :version => ‘0.11.6’

[…]

end

– end environment.rb –

Here’s the error message I receive when the require is left out.

– error –

me@machina $ script/ferret_server -e production start
undefined method `acts_as_ferret’ for #Class:0x22f9bec

– end snip –

Any ideas if this is normal?

I don’t use the AAF gem, but do have a require statement in a
initializer in config/intializers that pulls in acts_as_ferret. Any
chance you can supply a more detailed back trace that sheds some light
on what class is causing trouble? Do you also have trouble booting
script/console?

-c-

Dave A. wrote:

I recently upgraded to Rails 2.2.2 and refactored some of my rails code
to use the config.gem functionality. In doing so, I noticed some odd
behavior when trying to start the DrbServer. Essentially, the DrbServer
will not start unless I have the “require 'acts_as_ferret” statement
below in environment.rb. I thought the gem.config would have been
enough, but apparently not.

– start environment.rb –

Rails::Initializer.run do |config|

[…]

Requires acts_as_ferret must be here, can’t figure out why

require ‘acts_as_ferret’

config.gem ‘acts_as_ferret’, :version => ‘0.4.3’
config.gem ‘ferret’, :version => ‘0.11.6’

[…]

end

– end environment.rb –

Here’s the error message I receive when the require is left out.

– error –

me@machina $ script/ferret_server -e production start
undefined method `acts_as_ferret’ for #Class:0x22f9bec

– end snip –

Any ideas if this is normal?

Chris G. wrote:

I don’t use the AAF gem, but do have a require statement in a
initializer in config/intializers that pulls in acts_as_ferret.

For the DrbServer to start successfully, I must include a

require ‘acts_as_ferret’

…statement in my environment.rb file.

However, script/console and script/server startup just fine without the
require statement.

Any
chance you can supply a more detailed back trace that sheds some light
on what class is causing trouble? Do you also have trouble booting
script/console?

Here goes…

– debug message –

dgm@deimos $ script/ferret_server -e test start --debug
undefined method acts_as_ferret' for #<Class:0x22f9958> /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:inmethod_missing’
/Users/dgm/Sites/www.epartment54.com/app/models/article.rb:35
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in
require' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:inrequire_or_load’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in
depend_on' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:inrequire_dependency’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:368:in
load_application_classes' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:ineach’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
load_application_classes' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:ineach’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
load_application_classes' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:185:inprocess’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in send' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:inrun’
./script/…/config/environment.rb:13
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire’
/Library/Ruby/Gems/1.8/gems/acts_as_ferret-0.4.3/lib/server_manager.rb:39
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire’
script/ferret_server:9

– end debug –

– script/ferret_server –

#!/usr/bin/env ruby

begin
require File.join(File.dirname(FILE),
‘…/vendor/plugins/acts_as_ferret/lib/server_manager’)
rescue LoadError

try the gem

require ‘rubygems’
gem ‘acts_as_ferret’
require ‘server_manager’ # <-- This is line 9
end

– end script/ferret_server –

Notable points of interest:

  • article.rb is a model and has a “acts_as_ferret” hook at line 35
  • Line 35 of environment.rb is the “Rails::Initializer.run do |config|”
    start block. Within it I have a config.gem ‘acts_as_ferret’ statement.

My hunch is that config.gem is not loading things in a way that is
compatible with DrbServer. Ideas?