Home > database >  superclass must be an instance of Class (given an instance of Module) (TypeError) when doing `cucumb
superclass must be an instance of Class (given an instance of Module) (TypeError) when doing `cucumb

Time:11-22

I cant seem to be able to figure out

The error logs are as follow

superclass must be an instance of Class (given an instance of Module) (TypeError)
/home/asus/code/ruby-project/cucumber/config/application.rb:11:in `<module:Cucumber>'
/home/asus/code/ruby-project/cucumber/config/application.rb:9:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `require_relative'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `require'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `load_code_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:81:in `block in load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `each'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:278:in `load_step_definitions'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:74:in `run!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/cli/main.rb:29:in `execute!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/bin/cucumber:9:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `<main>'

The application.rb is as followed

require_relative "boot"

require "rails/all"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Cucumber
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 7.0

    # Configuration for the application, engines, and railties goes here.
    #
    # These settings can be overridden in specific environments using the files
    # in config/environments, which are processed later.
    #
    # config.time_zone = "Central Time (US & Canada)"
    # config.eager_load_paths << Rails.root.join("extras")
  end
end

There are threads with similar issues (ruby on rails : <top (required)>': superclass must be a Class (Symbol given) (TypeError)), I am not sure it can be applied in this case. I tried to reinstall rails, downgrading cucumber-rails. The issue is still persisted.

CodePudding user response:

I guess the problem is that you named your Ruby on Rails application Cucumber while having the cucumber gem installed too. And that this confuses Ruby.

I suggest naming your Ruby on Rails application differently and not using the same name as a well-known gem.

  • Related