goldfish1
@goldfish1

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

Ruby on railsでDevise gemを入れたら、ローカルサーバーが起動しなくなりました。助けてください。

解決したいこと

devise gemのNameエラー

Ruby on Railsでdevise gemを利用して認証機能を作成しようとしたところ、
deviseインストール後に以下のエラーが発生し、ローカルサーバーを起動できなくなりました。

発生している問題・エラー

uninitialized constant Devise (NameError)

Devise.setup do |config|
^^^^^^
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:667:in load' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:667:in block in load_config_initializer'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/notifications.rb:208:in instrument' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:666:in load_config_initializer'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:620:in block (2 levels) in <class:Engine>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:619:in each'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/engine.rb:619:in block in <class:Engine>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:32:in instance_exec'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:32:in run' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:61:in block in run_initializers'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:228:in block in tsort_each' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:422:in block (2 levels) in each_strongly_connected_component_from' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:431:in each_strongly_connected_component_from'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:421:in block in each_strongly_connected_component_from' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:50:in each'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:50:in tsort_each_child' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:415:in call'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:415:in each_strongly_connected_component_from' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:349:in block in each_strongly_connected_component'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:347:in each' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:347:in call'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:347:in each_strongly_connected_component' from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:226:in tsort_each'
from C:/Ruby32-x64/lib/ruby/3.2.0/tsort.rb:205:in tsort_each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:60:in run_initializers'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/application.rb:372:in initialize!' from C:/Users/719go/skApp/pdiary/config/environment.rb:5:in '
from config.ru:3:in require_relative' from config.ru:3:in block in '
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/builder.rb:116:in eval' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/builder.rb:116:in new_from_string'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/builder.rb:105:in load_file' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/builder.rb:66:in parse_file'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/server.rb:349:in build_app_and_options_from_config' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/server.rb:249:in app'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rack-2.2.9/lib/rack/server.rb:422:in wrapped_app' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/server/server_command.rb:76:in log_to_stdout'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/server/server_command.rb:36:in start' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/server/server_command.rb:143:in block in perform'
from internal:kernel:90:in tap' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/server/server_command.rb:134:in perform'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in run' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in invoke_command'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in dispatch' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/command/base.rb:87:in perform'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/command.rb:48:in invoke' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands.rb:18:in '
from internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require' from bin/rails:4:in '

自分で試したこと

一度deviseをアンインストールしたり、rubyのバージョンに合わせてアップデートをしました。
deviseファイルを削除するとローカルサーバーが起動しますが、deviseが消えてしまいました。

0

1Answer

Comments

  1. @goldfish1

    Questioner

    回答ありがとうございます。サーバーの再起動をしようとしたところ、先ほどのようなエラーが発生しました。

Your answer might help someone💌