【发布时间】:2022-03-13 20:55:32
【问题描述】:
在 Rails 7.0.0 中生成控制器时遇到问题
当我运行命令时
rails g controller Home index
它给了我以下错误。
/home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:103:in `block in preload': undefined method `mechanism=' for ActiveSupport::Dependencies:Module (NoMethodError)
from /home/dev/.rvm/gems/ruby-3.0.2/gems/railties-7.0.1/lib/rails/initializable.rb:32:in `instance_exec'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/railties-7.0.1/lib/rails/initializable.rb:32:in `run'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/railties-7.0.1/lib/rails/initializable.rb:61:in `block in run_initializers'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/railties-7.0.1/lib/rails/initializable.rb:60:in `run_initializers'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/railties-7.0.1/lib/rails/application.rb:372:in `initialize!'
from /home/dev/project/spousal/config/environment.rb:5:in `<main>'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /home/dev/.rvm/gems/ruby-3.0.2/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/home/dev/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>
我已经用谷歌搜索但没有找到解决方案。那么这个错误的原因是什么?
【问题讨论】:
标签: dependencies activesupport