1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails5.2でセッション管理をActive Recordに変えようとしたらエラー

Posted at

環境

Windows10
-> Ruby -> 2.5.1
-> Rails -> 5.2.0

以下エラー

console
Traceback (most recent call last):
        53: from bin/rails:4:in `<main>'
        52: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
        51: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
        50: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
        49: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
        48: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
        47: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'
        46: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
        45: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
        44: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        43: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/generate/generate_command.rb:21:in `perform'
        40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/actions.rb:18:in `require_application_and_environment!'
        39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'
        38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
        37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
        36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
        35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
        34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
        33: from C:/Users/coron/Documents/02_foundings/services/Intara-Vote/config/environment.rb:5:in `<top (required)>'
        32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
        31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
        30: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
        29: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
        28: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
        27: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in `call'
        26: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in `each'
        25: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
        24: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:415:in `each_strongly_connected_component_from'
        23: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:415:in `call'
        22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:50:in `tsort_each_child'
        21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:50:in `each'
        20: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        19: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
        18: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        17: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        16: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
        15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
        14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
        13: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
        12: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:613:in `block in <class:Engine>'
        11: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:613:in `each'
        10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:614:in `block (2 levels) in <class:Engine>'
         9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:656:in `load_config_initializer'
         8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/notifications.rb:170:in `instrument'
         7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:657:in `block in load_config_initializer'
         6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
         5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
         4: from C:/Users/coron/Documents/02_foundings/services/Intara-Vote/config/initializers/session_store.rb:1:in `<top (required)>'
         3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:42:in `load_missing_constant'
         2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `rescue in load_missing_constant'
         1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant AppName (NameError)

なにをしようとしたか

Railsにはセッション管理方法として、主に3つある。
そのうちのActive Recordを使ったセッション管理をしたかったのだが、環境構築中にエラーがおきた。

Active Record-Session_storeというGemを使った環境構築時、必ず以下のコマンドを実行する。
READMEにかいてあったもん。

$ rails generate active_record:session_migration

このとき上述したエラーがおきた。

回避

1.Gemfileの編集。bootsnapを定義している行をコメントアウト

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

2.Bundleアップデート

$ bundle update

3.さっきのコマンド実行

$ rails generate active_record:session_migration

4.Gemfileを戻す

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

おわり

こんな小さなエラーでしたが、このエラー原因がbootsnapではないことを誰かに教えてほしかったのです。
もし明確なエラー原因をご存知でしたら、お教えください。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?