I've just updated my ruby installation on my gentoo server to ruby 1.8.6 patchlevel 287 and have started getting an error on one of my eRuby apps. The error given in the apache error_log file is:
[error] mod_ruby: /usr/lib/ruby/1.8/cgi.rb:774: superclass mismatch for class Cookie (TypeError)
The strange thing is that it seems to work sometimes - but other times I get that error. Anyone any ideas?
As the error message says, there is an opening of the Cookie class somewhere in the code that is using a different superclass than the one used in a prior definition or opening of the Cookie class.
Even a class definition that does not explicitly specify a superclass still has a superclass:
class Cookie
end
This defines the Cookie class with the superclass of Object.
I've encountered this error before, and it will occur when you have some code trying to reopen a class without specifying the superclass, and the programmer's assumption is that the class (in this case, Cookie) has already been defined, and that he is simply reopening it to add some functionality. But if the reopening and the definition are in reverse order, you'll get that error because the class will already have been defined as a subclass of Object, but is trying to be redefined or reopened with a different superclass. Try this in irb:
% irb
irb(main):001:0> class C < String; end
=> nil
irb(main):002:0> class C; end
=> nil
irb(main):003:0> exit
% irb
irb(main):001:0> class C; end
=> nil
irb(main):002:0> class C < String; end
TypeError: superclass mismatch for class C
from (irb):2
So, you probably just have to grep for definitions of the Cookie class and try to ensure files are always being require-d in the correct order. This may or may not be easy. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With