问题
I assume I'm in gem dependency hell here, but if anyone can help I'd be much appreciated (Googling for "cannot remove Object::NotSupported" literally returned zero results).
I have a Rails 2.3.5 app and I get this stack trace on initialization:
usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:603:in `remove_const': cannot remove Object::NotSupported (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:603:in `remove_constant'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:603:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:603:in `remove_constant'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:549:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:549:in `each'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:549:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:622:in `load_application_initializers'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `each'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `load_application_initializers'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:176:in `process'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from /data/groupsale/releases/20101214214330/config/environment.rb:9
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3
I've gone through each of the config.gem lines, then started deleting initializers, until this error went away and I started seeing "real" errors (about the things I removed) but I haven't been able to pinpoint the offending one. Does anyone have (a) any advice on a better way to troubleshoot this, or (b) does Object::NotSupported ring any bells... it almost seems suspiciously generic.
Thanks, Tom
P.S. Gem list as follows:
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (3.0.1, 2.3.5)
aws (2.3.26)
aws-s3 (0.6.2)
barby (0.4.2)
bitly (0.5.3)
bson (1.1.4)
bson_ext (1.1.4)
builder (2.1.2)
crack (0.1.8)
devise (1.0.9)
erubis (2.6.2)
eventmachine (0.12.6)
exceptional (2.0.26)
extlib (0.9.9)
eyrubygems (0.0.2)
facebooker (1.0.75)
facter (1.5.2)
fastercsv (1.5.3)
fastthread (1.0.7)
ferret (0.11.6)
forgery (0.3.4)
formtastic (0.9.7)
hoe (2.8.0)
hominid (2.1.0)
http_connection (1.4.0)
httparty (0.6.1)
i18n (0.5.0)
igrigorik-em-http-request (0.1.5)
jnunemaker-validatable (1.8.4)
json (1.1.3)
json_pure (1.4.6)
mime-types (1.16)
mini_magick (2.3)
money (3.1.5)
mongo (1.1.4)
mongo_ext (0.19.3)
mongo_mapper (0.8.6)
navvy (0.3.1)
ohai (0.2.0)
open4 (0.9.6)
paginator (1.1.1)
passenger (2.2.8)
plucky (0.3.6)
rack (1.0.1)
rails (2.3.5)
rails-footnotes (3.6.7)
rake (0.8.7)
RedCloth (4.2.3)
rest-client (0.9.2)
right_aws (1.10.0)
right_http_connection (1.2.4)
rmagick (2.12.2)
ruby-hmac (0.4.0)
ruby-openid (2.1.2)
rubyforge (2.0.4)
rubygems-update (1.3.6)
sparklines (0.5.2)
stomp (1.0.6)
subexec (0.0.4)
uuidtools (2.1.1)
warden (1.0.2)
whenever (0.6.2)
xml-simple (1.0.12)
yui-compressor (0.9.1)
zendesk_remote_auth (0.9.0)
回答1:
So, simplest way I found to debug this was to crack open /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb and add a line to log which things it was loading. That way I was able to isolate the bad initializer.
The root cause of this problem was that in an initializer, it was trying to YAML::load a config file that wasn't present on the machine.
回答2:
try removing erubis from your gemfile as well.
I am getting that same error "ERROR NameError: cannot remove Object::KEY" with Erubis 2.6.5
and without that gem, I'm getting an error inside the view, which I have a clear error with stacktrace popping up
hope this helps.
来源:https://stackoverflow.com/questions/4444649/rails-2-3-5-startup-remove-const-cannot-remove-objectnotsupported-nameerror