Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding psych causes CircleCI to fail with 'TypeError: superclass mismatch for class Mark' #386

Open
henrik opened this issue Feb 20, 2019 · 11 comments

Comments

@henrik
Copy link

@henrik henrik commented Feb 20, 2019

We upgraded Rubocop from 0.64.0 to 0.65.0. This added a dependency on psych 3.1.0.

The tests for our app on Ruby 2.5.3 and Rails 4.2.11 started failing in CircleCI with:

rake aborted!
TypeError: superclass mismatch for class Mark
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/faker-1.9.3/lib/faker.rb:6:in `<top (required)>'
/home/circleci/project/config/application.rb:13:in `<top (required)>'
/home/circleci/project/Rakefile:14:in `require'
/home/circleci/project/Rakefile:14:in `block in <top (required)>'
/home/circleci/project/lib/tasks/no_rails_rake_tasks.rb:9:in `load_rails'
/home/circleci/project/lib/tasks/no_rails_rake_tasks.rb:32:in `top_level'
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:30:in `block in <main>'
/usr/local/bin/bundle:22:in `<main>'
(See full trace by running task with --trace)

(I'm not sure why the backtrace says "ruby/2.5.0" instead of 2.5.3.)

We also get some warnings like

/usr/local/lib/ruby/2.5.0/psych/versions.rb:4: warning: already initialized constant Psych::VERSION
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/psych-3.1.0/lib/psych/versions.rb:5: warning: previous definition of VERSION was here
/usr/local/lib/ruby/2.5.0/psych/versions.rb:4: warning: already initialized constant Psych::VERSION
/home/circleci/project/vendor/bundle/ruby/2.5.0/gems/psych-3.1.0/lib/psych/versions.rb:5: warning: previous definition of VERSION was here
/usr/local/lib/ruby/2.5.0/x86_64-linux/psych.so: warning: already initialized constant Psych::Parser::ANY

if that's relevant.

@rmm5t
Copy link

@rmm5t rmm5t commented Feb 20, 2019

I'm not sure why the backtrace says "ruby/2.5.0" instead of 2.5.3

FYI: That's just how ruby and rubygems and hence bundler manages the directory path for gems. Ruby 2.5.1, 2.5.2, 2.5.3, etc will all use the same gem load path of ruby/2.5.0/gems... You'll see the same behavior in the installation directory of ruby itself.

@yuki24
Copy link
Member

@yuki24 yuki24 commented Feb 22, 2019

It seems like you have a top-level Mark class somewhere in your app, and it caused a conflict with the Parser::Mark class:

class Mark < Struct.new(:index, :line, :column)

I think requiring Psych may fix the issue, but I'm not 100% sure. Given that this code has been there since 2011, I think there's something to do with other dependencies.

@yuki24 yuki24 closed this Feb 22, 2019
@yuki24 yuki24 reopened this Feb 22, 2019
@majioa
Copy link

@majioa majioa commented Mar 5, 2019

I have the same failure in case of loading Gem::Specification yaml document.

The log is below:

    74: from /usr/lib/ruby/gems/2.5.0/bin/ruby_executable_hooks:24:in `<main>'
    73: from /usr/lib/ruby/gems/2.5.0/bin/ruby_executable_hooks:24:in `eval'
    72: from /usr/lib/ruby/gems/2.5.0/bin/setup.rb:23:in `<main>'
    71: from /usr/lib/ruby/gems/2.5.0/bin/setup.rb:23:in `load'
    70: from /home/majioa/git/ruby-setup2/bin/setup.rb:27:in `<top (required)>'
    69: from /home/majioa/git/ruby-setup2/lib/setup/command.rb:18:in `run'
    68: from /home/majioa/git/ruby-setup2/lib/setup/command.rb:99:in `run'
    67: from /usr/lib/ruby/optparse.rb:1648:in `parse!'
    66: from /usr/lib/ruby/optparse.rb:1626:in `permute!'
    65: from /usr/lib/ruby/optparse.rb:1532:in `order!'
    64: from /usr/lib/ruby/optparse.rb:1538:in `parse_in_order'
    63: from /usr/lib/ruby/optparse.rb:1538:in `catch'
    62: from /usr/lib/ruby/optparse.rb:1552:in `block in parse_in_order'
    61: from /home/majioa/git/ruby-setup2/lib/setup/command.rb:236:in `block in optparse_install'
    60: from /home/majioa/git/ruby-setup2/lib/setup/command.rb:157:in `configuration'
    59: from /home/majioa/git/ruby-setup2/lib/setup/session.rb:211:in `configuration'
    58: from /home/majioa/git/ruby-setup2/lib/setup/session.rb:211:in `new'
    57: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:155:in `initialize'
    56: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:197:in `initialize_configfile'
    55: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:197:in `each'
    54: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:202:in `block in initialize_configfile'
    53: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:315:in `project='
    52: from /home/majioa/git/ruby-setup2/lib/setup/configuration.rb:315:in `new'
    51: from /home/majioa/git/ruby-setup2/lib/setup/project.rb:37:in `initialize'
    50: from /home/majioa/git/ruby-setup2/lib/setup/project.rb:109:in `sources='
    49: from /home/majioa/git/ruby-setup2/lib/setup/project.rb:109:in `map'
    48: from /home/majioa/git/ruby-setup2/lib/setup/project.rb:114:in `block in sources='
    47: from /home/majioa/git/ruby-setup2/lib/setup/project.rb:114:in `new'
    46: from /home/majioa/git/ruby-setup2/lib/setup/source/gem.rb:266:in `initialize'
    45: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych.rb:279:in `load'
    44: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/nodes/node.rb:50:in `to_ruby'
    43: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:32:in `accept'
    42: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
    41: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:16:in `visit'
    40: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:311:in `visit_Psych_Nodes_Document'
    39: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:32:in `accept'
    38: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
    37: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:16:in `visit'
    36: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
    35: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:374:in `revive'
    34: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `revive_hash'
    33: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `each_slice'
    32: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `each'
    31: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:338:in `block in revive_hash'
    30: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:32:in `accept'
    29: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
    28: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:16:in `visit'
    27: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:141:in `visit_Psych_Nodes_Sequence'
    26: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:330:in `register_empty'
    25: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:330:in `each'
    24: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:330:in `block in register_empty'
    23: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:32:in `accept'
    22: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
    21: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:16:in `visit'
    20: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
    19: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:374:in `revive'
    18: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `revive_hash'
    17: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `each_slice'
    16: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336:in `each'
    15: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:338:in `block in revive_hash'
    14: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:32:in `accept'
    13: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
    12: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:16:in `visit'
    11: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
    10: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:374:in `revive'
     9: from /usr/lib/ruby/gems/2.5.0/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:382:in `init_with'
     8: from /usr/lib/ruby/rubygems/requirement.rb:215:in `init_with'
     7: from /usr/lib/ruby/rubygems/requirement.rb:210:in `yaml_initialize'
     6: from /usr/lib/ruby/rubygems.rb:699:in `load_yaml'
     5: from /usr/lib/ruby/rubygems.rb:699:in `require'
     4: from /usr/lib/ruby/psych.rb:19:in `<top (required)>'
     3: from /usr/lib/ruby/psych.rb:19:in `require'
     2: from /usr/lib/ruby/psych/parser.rb:2:in `<top (required)>'
     1: from /usr/lib/ruby/psych/parser.rb:33:in `<module:Psych>'

/usr/lib/ruby/psych/parser.rb:34:in `class:Parser': superclass mismatch for class Mark (TypeError)

The error is risen when both default and custom gems are installed, only when gespec is being parsed.

@coldnebo
Copy link

@coldnebo coldnebo commented Mar 8, 2019

As soon as another team installed psych v3.1.0 (as part of a Rails 5 update?) into our common gemdir, we started seeing failures in Rails3 rake tasks.

This seems to be loaded outside of bundler's context?

I was able to reproduce this failure by installing 3.1.0 directly:

$ gem list psych

*** LOCAL GEMS ***

psych (default: 2.1.0.1)

$ bundle exec rake -T
rake assets:clean                                    # Remove compiled assets
rake assets:precompile                               # Compile all the assets named in config.assets.precompile
rake clean                                           # Remove any temporary products
rake clobber                                         # Remove any generated files
...

$ gem install psych -v=3.1.0
Fetching: psych-3.1.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed psych-3.1.0
1 gem installed

$ gem list psych

*** LOCAL GEMS ***

psych (3.1.0, default: 2.1.0.1)

$ bundle exec rake -T
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-linux/psych.so: warning: already initialized constant Psych::Parser::ANY
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-linux/psych.so: warning: already initialized constant Psych::Parser::UTF8
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-linux/psych.so: warning: already initialized constant Psych::Parser::UTF16LE
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-linux/psych.so: warning: already initialized constant Psych::Parser::UTF16BE
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:7: warning: already initialized constant Psych::ClassLoader::BIG_DECIMAL
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:7: warning: previous definition of BIG_DECIMAL was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:8: warning: already initialized constant Psych::ClassLoader::COMPLEX
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:8: warning: previous definition of COMPLEX was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:9: warning: already initialized constant Psych::ClassLoader::DATE
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:9: warning: previous definition of DATE was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:10: warning: already initialized constant Psych::ClassLoader::DATE_TIME
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:10: warning: previous definition of DATE_TIME was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:11: warning: already initialized constant Psych::ClassLoader::EXCEPTION
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:11: warning: previous definition of EXCEPTION was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:12: warning: already initialized constant Psych::ClassLoader::OBJECT
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:12: warning: previous definition of OBJECT was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:13: warning: already initialized constant Psych::ClassLoader::PSYCH_OMAP
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:13: warning: previous definition of PSYCH_OMAP was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:14: warning: already initialized constant Psych::ClassLoader::PSYCH_SET
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:14: warning: previous definition of PSYCH_SET was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:15: warning: already initialized constant Psych::ClassLoader::RANGE
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:15: warning: previous definition of RANGE was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:16: warning: already initialized constant Psych::ClassLoader::RATIONAL
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:16: warning: previous definition of RATIONAL was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:17: warning: already initialized constant Psych::ClassLoader::REGEXP
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:17: warning: previous definition of REGEXP was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:18: warning: already initialized constant Psych::ClassLoader::STRUCT
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:18: warning: previous definition of STRUCT was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:19: warning: already initialized constant Psych::ClassLoader::SYMBOL
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:19: warning: previous definition of SYMBOL was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/class_loader.rb:65: warning: already initialized constant Psych::ClassLoader::CACHE
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/class_loader.rb:65: warning: previous definition of CACHE was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/scalar_scanner.rb:9: warning: already initialized constant Psych::ScalarScanner::TIME
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:9: warning: previous definition of TIME was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/scalar_scanner.rb:12: warning: already initialized constant Psych::ScalarScanner::FLOAT
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:12: warning: previous definition of FLOAT was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/scalar_scanner.rb:18: warning: already initialized constant Psych::ScalarScanner::INTEGER
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:17: warning: previous definition of INTEGER was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/stream.rb:13: warning: already initialized constant Psych::Nodes::Stream::ANY
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/stream.rb:13: warning: previous definition of ANY was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/stream.rb:16: warning: already initialized constant Psych::Nodes::Stream::UTF8
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/stream.rb:16: warning: previous definition of UTF8 was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/stream.rb:19: warning: already initialized constant Psych::Nodes::Stream::UTF16LE
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/stream.rb:19: warning: previous definition of UTF16LE was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/stream.rb:22: warning: already initialized constant Psych::Nodes::Stream::UTF16BE
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/stream.rb:22: warning: previous definition of UTF16BE was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/sequence.rb:43: warning: already initialized constant Psych::Nodes::Sequence::ANY
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:43: warning: previous definition of ANY was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/sequence.rb:46: warning: already initialized constant Psych::Nodes::Sequence::BLOCK
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:46: warning: previous definition of BLOCK was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/sequence.rb:49: warning: already initialized constant Psych::Nodes::Sequence::FLOW
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:49: warning: previous definition of FLOW was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:10: warning: already initialized constant Psych::Nodes::Scalar::ANY
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:10: warning: previous definition of ANY was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:13: warning: already initialized constant Psych::Nodes::Scalar::PLAIN
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:13: warning: previous definition of PLAIN was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:16: warning: already initialized constant Psych::Nodes::Scalar::SINGLE_QUOTED
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:16: warning: previous definition of SINGLE_QUOTED was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:19: warning: already initialized constant Psych::Nodes::Scalar::DOUBLE_QUOTED
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:19: warning: previous definition of DOUBLE_QUOTED was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:22: warning: already initialized constant Psych::Nodes::Scalar::LITERAL
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:22: warning: previous definition of LITERAL was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/scalar.rb:25: warning: already initialized constant Psych::Nodes::Scalar::FOLDED
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:25: warning: previous definition of FOLDED was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/mapping.rb:17: warning: already initialized constant Psych::Nodes::Mapping::ANY
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:17: warning: previous definition of ANY was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/mapping.rb:20: warning: already initialized constant Psych::Nodes::Mapping::BLOCK
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:20: warning: previous definition of BLOCK was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/nodes/mapping.rb:23: warning: already initialized constant Psych::Nodes::Mapping::FLOW
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:23: warning: previous definition of FLOW was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/visitors/visitor.rb:11: warning: already initialized constant Psych::Visitors::Visitor::DISPATCH
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:11: warning: previous definition of DISPATCH was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:334: warning: already initialized constant Psych::Visitors::ToRuby::SHOVEL
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:334: warning: previous definition of SHOVEL was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/handler.rb:27: warning: already initialized constant Psych::Handler::OPTIONS
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/handler.rb:27: warning: previous definition of OPTIONS was here
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/psych/handler.rb:30: warning: already initialized constant Psych::Handler::EVENTS
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/psych-3.1.0/lib/psych/handler.rb:30: warning: previous definition of EVENTS was here
rake aborted!
TypeError: superclass mismatch for class Mark
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/activesupport-3.2.22.4/lib/active_support/ordered_hash.rb:2:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/activesupport-3.2.22.4/lib/active_support/ordered_hash.rb:2:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/activesupport-3.2.22.4/lib/active_support/ordered_options.rb:1:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/activesupport-3.2.22.4/lib/active_support/ordered_options.rb:1:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/configuration.rb:2:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/configuration.rb:2:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/railtie.rb:2:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/railtie.rb:2:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/engine.rb:1:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/engine.rb:1:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/plugin.rb:1:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/plugin.rb:1:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/application.rb:3:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/application.rb:3:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails.rb:10:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails.rb:10:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/all.rb:1:in `require'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/railties-3.2.22.4/lib/rails/all.rb:1:in `<top (required)>'
/local/myrailsapp/config/application.rb:3:in `require'
/local/myrailsapp/config/application.rb:3:in `<top (required)>'
/local/myrailsapp/Rakefile:5:in `require'
/local/myrailsapp/Rakefile:5:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/bin/ruby_executable_hooks:24:in `eval'
/shared/rvm/gems/ruby-2.3.7@myrailsapp/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)

I tried to add this explicitly to my Gemfile, but got another error then:

$ grep psych Gemfile*
Gemfile:  gem 'psych', '~> 2.1'
Gemfile.lock:    psych (2.2.4)
Gemfile.lock:  psych (~> 2.1)!

$ bundle exec rake -T
/shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated psych 3.1.0, but your Gemfile requires psych 2.2.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:31:in `block in setup'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/forwardable.rb:202:in `each'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/forwardable.rb:202:in `each'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:26:in `map'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:26:in `setup'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler.rb:107:in `setup'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/bundler/setup.rb:10:in `<top (required)>'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /shared/rvm/rubies/ruby-2.3.7/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
@coldnebo
Copy link

@coldnebo coldnebo commented Mar 8, 2019

UPDATE: it seems that rubocop 0.65.0 has a dependency on psych 3.1.0 and pulled it in.

WORKAROUND: As I mention in Rubocop's issue thread, this seems to be because they require psych 3.1.0 and have a ruby version requirement >= 2.2.2

gem 'rubocop', '<= 0.64.0'

Psych is tightly integrated to Ruby core, so it is dangerous for Rubocop to spec it without a higher ruby version requirement.

Note:

  • Ruby 2.6.1 depends on psych 3.1.0
  • Ruby 2.6.0 made the switch to psych 3.1.0
  • Ruby 2.5.0 made the switch to psych 3.0.0
  • Ruby 2.3.7 depends on psych 2.1.0.1
@junaruga
Copy link
Contributor

@junaruga junaruga commented May 14, 2020

Dear people who faced this issue. Does the following script work on your environment?

$ cat test.rb 
require 'psych'
Gem.load_yaml
$ ruby test.rb 

What is the result of the following command?

$ gem info psych

Because I faced the error in Fedora RPM Ruby here.
https://bugzilla.redhat.com/show_bug.cgi?id=1835836

@junaruga
Copy link
Contributor

@junaruga junaruga commented May 15, 2020

It seems that this issue comes from rubygems/rubygems#3131 .

@junaruga
Copy link
Contributor

@junaruga junaruga commented May 15, 2020

Maybe here is the temporary workflow to avoid the issue, that I reported here.

<mock-chroot> sh-5.0# diff -u /usr/share/rubygems/rubygems.rb{.orig,}
--- /usr/share/rubygems/rubygems.rb.orig	2020-03-31 12:44:55.000000000 +0200
+++ /usr/share/rubygems/rubygems.rb	2020-05-15 11:43:34.851595500 +0200
@@ -685,7 +685,11 @@
     return unless defined?(gem)
 
     begin
-      gem 'psych', '>= 2.0.0'
+      begin
+        require 'psych'
+      rescue ::LoadError
+        gem 'psych', '>= 2.0.0'
+      end
     rescue Gem::LoadError
       # It's OK if the user does not have the psych gem installed.  We will
       # attempt to require the stdlib version
@junaruga
Copy link
Contributor

@junaruga junaruga commented May 15, 2020

For rubocop, it seems the they dropped psych. Maybe this issue does not happen with rubocop >= 0.68.0. rubocop-hq/rubocop@95d2110

@junaruga
Copy link
Contributor

@junaruga junaruga commented May 20, 2020

Maybe when you use rubygems applying the following one or both of the following commits, the issue does not happen.

rubygems/rubygems@f3da3c1
rubygems/rubygems@1ccf091

@wy-ruby
Copy link

@wy-ruby wy-ruby commented Sep 24, 2020

You can try the following code in irb/pry console

class One
end

class Two
end

class Test < Two
end

Class Test < One
end

This is the kind of error reported

TypeError: superclass mismatch for class Test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.