微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

运行 rake/rails 命令时,我收到 `TypeError: superclass mismatch for class Command`

如何解决运行 rake/rails 命令时,我收到 `TypeError: superclass mismatch for class Command`

我正在尝试在 Linux 上使用 rails/rake 运行命令,例如:rails db:resetrake --tasks。但是当我这样做时,我收到以下错误

$ rake --tasks
rake aborted!
TypeError: superclass mismatch for class Command
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:2:in `<class:Thor>'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:1:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:1:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/group.rb:1:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/generators.rb:6:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/app_updater.rb:3:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks/framework.rake:41:in `block (2 levels) in <main>'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks/framework.rake:40:in `block in <main>'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks/framework.rake:3:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:77:in `load'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:77:in `load'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:318:in `block in load'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:318:in `load'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks.rb:22:in `block in <main>'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks.rb:21:in `each'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/tasks.rb:21:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:519:in `run_tasks_blocks'
/var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/engine.rb:459:in `load_tasks'
/home/momentus/stackshine/Rakefile:9:in `<top (required)>'
/usr/share/rubygems-integration/all/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)

bundle exec 放在命令前面没有帮助。唯一不会出现此错误 (afaik) 的命令是 rails srails c

这是我的 Gemfile:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.7.1"

# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem "rails","~> 6.0.3",">= 6.0.3.2"
# Use postgresql as the database for Active Record
gem "pg",">= 0.18","< 2.0"
# Use Puma as the app server
gem "puma","~> 4.1"
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem "webpacker","~> 4.0"
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem "turbolinks","~> 5"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem "jbuilder","~> 2.7"
# Use Redis adapter to run Action Cable in production
# gem 'redis','~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt','~> 3.1.7'

# Offer a real backend for ActiveJob
gem "resque"
gem "resque-scheduler"
gem "resque-web",require: "resque_web"

# Turbocharge complex front-end components
gem "react-rails"

# Integrate directly with our team chat
gem "discordrb"

# Use Active Storage variant
# gem 'image_processing','~> 1.2'

# Add .active class to links when they're being presented
gem "active_link_to"

# Tell StatsD about request time,GC,objects and more.
gem "barnes"

# Save time on form stuff
gem "simple_form"

# Authentication via Auth0
gem "omniauth-auth0","~> 2.2"
gem "omniauth-rails_csrf_protection","~> 0.1"

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap",">= 1.4.2",require: false

# Scrape websites to extract vendor data
gem "kimurai"

# Name management
gem "name_of_person"

# Allow models to be tagged
gem "acts-as-taggable-on","~> 6.0"

# Keep track of env vars alongside the app
gem "dotenv-rails",groups: [:development,:test]

group :development,:test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem "byebug",platforms: [:mri,:mingw,:x64_mingw]
  gem "pry-rails"
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem "web-console",">= 3.3.0"
  gem "listen","~> 3.2"
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem "spring"
  gem "spring-watcher-listen","~> 2.0.0"

  gem "better_errors"
  gem "binding_of_caller"

  # Watch for n+1 queries to maintain performance
  gem "bullet"
end

# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem "tzinfo-data",platforms: [:mingw,:mswin,:x64_mingw,:jruby]

gem "selenium-webdriver"

gem "aws-sdk-s3",require: false

gem "plaid"

gem "stripe"
gem "stripe_event" # webhook library

gem "sentry-ruby"
gem "sentry-rails"

gem "paranoia","~> 2.2"

gem "rails_admin","~> 2.0"

gem "sib-api-v3-sdk"

gem "google-apis-admin_directory_v1"
gem "google-apis-admin_reports_v1"

gem "google-id-token"

# Quickbooks Online API library
gem "quickbooks-ruby"

gem "httparty"

gem 'rack-reverse-proxy',:require => 'rack/reverse_proxy'

gem "noticed",git: "https://github.com/excid3/noticed"

gem "newrelic_rpm"

gem "storext"

gem "multipart-parser"

gem "cancancan"

gem 'mimemagic',github: 'mimemagicrb/mimemagic',ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。