Bug #13180
closed'superclass mismatch for class' on nested classes
Description
I've been seeing the following errors when attempting to run different ruby projects.
/usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/digest.rb:57:in `<class:Digest>': superclass mismatch for class Digest (TypeError)
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/digest.rb:16:in `<module:OpenSSL>'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/digest.rb:15:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl.rb:19:in `require'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl.rb:19:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:8:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:8:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/connection.rb:9:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/connection.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:2775:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:2775:in `<top (required)>'
from /Users/adam/src/banno/banno-utility-belt/lib/sneakily_grant_auth.rb:2:in `require'
from /Users/adam/src/banno/banno-utility-belt/lib/sneakily_grant_auth.rb:2:in `<top (required)>'
from /Users/adam/src/banno/banno-utility-belt/libexec/bub-api.rb:2:in `require'
from /Users/adam/src/banno/banno-utility-belt/libexec/bub-api.rb:2:in `<top (required)>'
from /Users/adam/bin/bub:19:in `load'
from /Users/adam/bin/bub:19:in `block in <main>'
from /Users/adam/bin/bub:19:in `each'
from /Users/adam/bin/bub:19:in `<main>'
I get a similar error with the Cipher class also.
/usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:64:in `<class:Cipher>': superclass mismatch for class Cipher (TypeError)
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:16:in `<module:OpenSSL>'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:15:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl.rb:17:in `require'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/openssl.rb:17:in `<top (required)>'
I was able to get my programs to run by commenting out line 57 in digest.rb and line 64 in cipher.rb. For reference, the lines were:
cipher.rb: class Cipher < Cipher; end
digest.rb: class Digest < Digest; end # :nodoc:
I tried for a few minutes to reproduce this with the following, but was unable to see the error. (Running the file through ruby produced no error.)
class Foo
class Foo < Foo; end
end
Updated by shyouhei (Shyouhei Urabe) over 8 years ago
I wonder if it has something to do with issue #11547? Might be fixed in the latest trunk if that is the case.
Updated by rhenium (Kazuki Yamaguchi) over 8 years ago
- Status changed from Open to Third Party's Issue
(Assuming you are using Bundler...) It is because openssl is loaded two times.
https://github.com/bundler/bundler/pull/5388
Regarding the error:
$ ruby -e'2.times{class A; class A < A; end end}'
-e:1:in `<class:A>': superclass mismatch for class A (TypeError)
from -e:1:in `block in <main>'
from -e:1:in `times'
from -e:1:in `<main>'
Updated by adamdecaf (Adam Shannon) over 8 years ago
Thanks for the quick patches. Would those likely be released in upcoming bug fixes? I can keep using my forked versions and reinstall once releases are out.