graphql_devise: Error on rails s: uninitialized constant DeviseTokenAuth::Concerns::TokensSerialization (NameError)
Describe the bug
Getting uninitialized constant error upon starting up rails server
/Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise_token_auth-1.1.4/app/models/devise_token_auth/concerns/active_record_support.rb:7:in `block in <module:ActiveRecordSupport>': uninitialized constant DeviseTokenAuth::Concerns::TokensSerialization (NameError)
Environment
Steps to reproduce
- Run
rails s - See uninitialized constant error
Expected behavior
Expected the server to be able to start as normal
Actual behavior
Traceback (most recent call last):
112: from bin/rails:3:in `<main>'
111: from bin/rails:3:in `load'
110: from /Users/danloman/Code/citizenwe-backend/bin/spring:15:in `<top (required)>'
109: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
108: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
107: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
106: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
105: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
104: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
103: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
102: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
101: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
100: from /Users/danloman/Code/citizenwe-backend/bin/rails:9:in `<top (required)>'
99: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
98: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
97: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
96: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
95: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
94: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
93: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
92: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
91: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands.rb:18:in `<main>'
90: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command.rb:46:in `invoke'
89: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command/base.rb:69:in `perform'
88: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
87: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
86: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
85: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:138:in `perform'
84: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:138:in `tap'
83: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
82: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:37:in `start'
81: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:77:in `log_to_stdout'
80: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
79: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
78: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
77: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
76: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
75: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
74: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
73: from config.ru:3:in `block in <main>'
72: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
71: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
70: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
69: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
68: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
67: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
66: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
65: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
64: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
63: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
62: from /Users/danloman/Code/citizenwe-backend/config/environment.rb:6:in `<main>'
61: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application.rb:363:in `initialize!'
60: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:60:in `run_initializers'
59: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
58: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
57: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
56: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `call'
55: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each'
54: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
53: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
52: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
51: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
50: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
49: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `run'
48: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `instance_exec'
47: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/finisher.rb:184:in `block in <module:Finisher>'
46: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:10:in `execute'
45: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/file_update_checker.rb:83:in `execute'
44: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:29:in `block in updater'
43: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:20:in `reload!'
42: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
41: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:40:in `each'
40: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
39: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
38: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
37: from /Users/danloman/Code/citizenwe-backend/config/routes.rb:2:in `<main>'
36: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.2/lib/action_dispatch/routing/route_set.rb:408:in `draw'
35: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.2/lib/action_dispatch/routing/route_set.rb:426:in `eval_block'
34: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.2/lib/action_dispatch/routing/route_set.rb:426:in `instance_exec'
33: from /Users/danloman/Code/citizenwe-backend/config/routes.rb:4:in `block in <main>'
32: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/rails/routes.rb:242:in `devise_for'
31: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/rails/routes.rb:242:in `each'
30: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/rails/routes.rb:243:in `block in devise_for'
29: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise.rb:346:in `add_mapping'
28: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise.rb:346:in `new'
27: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/mapping.rb:72:in `initialize'
26: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/mapping.rb:162:in `default_used_route'
25: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/mapping.rb:95:in `routes'
24: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/mapping.rb:78:in `modules'
23: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise/mapping.rb:83:in `to'
22: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.2/lib/devise.rb:316:in `get'
21: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize'
20: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/inflector/methods.rb:280:in `constantize'
19: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/inflector/methods.rb:280:in `inject'
18: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/inflector/methods.rb:280:in `each'
17: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/inflector/methods.rb:282:in `block in constantize'
16: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/inflector/methods.rb:282:in `const_get'
15: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `require'
14: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
13: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
12: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
11: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
10: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
9: from /Users/danloman/Code/citizenwe-backend/app/models/user.rb:1:in `<main>'
8: from /Users/danloman/Code/citizenwe-backend/app/models/user.rb:15:in `<class:User>'
7: from /Users/danloman/Code/citizenwe-backend/app/models/user.rb:15:in `include'
6: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `append_features'
5: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `class_eval'
4: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise_token_auth-1.1.4/app/models/devise_token_auth/concerns/user.rb:25:in `block in <module:User>'
3: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise_token_auth-1.1.4/app/models/devise_token_auth/concerns/user.rb:25:in `include'
2: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `append_features'
1: from /Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `class_eval'
/Users/danloman/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise_token_auth-1.1.4/app/models/devise_token_auth/concerns/active_record_support.rb:7:in `block in <module:ActiveRecordSupport>': uninitialized constant DeviseTokenAuth::Concerns::TokensSerialization (NameError)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (9 by maintainers)
Hey! we encountered the same issue in our App, but luckily it was long after the initial setup, so that helped narrow the problem. I cannot offer a definitive solution, only some hints. In our case, it was caused by an initializer referencing an ActiveRecord Model (in fact it was not even referencing the model directly, only it’s stringified name “myModel”, but the code that the related gem was calling
const_get("MyModel")).The setup
uninitialized constant DeviseTokenAuth::Concerns::TokensSerializationThe solution in our case
Switching the initializer to run later fixed the problem.
Code before:
Excerpt from the Zeitwerk loading logs:
Code after:
Excerpt from the Zeitwerk loading logs:
Like I said above, delaying initialization feels more of a workaround than a proper fix, but I didn’t have the time to dig down in this gem (and DTAs) to find the culprit. I hope that it can help people with the same error to narrow their problem.
Hey @namolnad, I can confirm I got the same error message on the generator about the file not found and I will look into that. But that doesn’t stop the generator to complete installation. Anyway, looks like an autoload problem with Rails, and in a weird place as it happens inside DTA’s gem code. You shouldn’t have a problem if both initializers are generated properly.
Could you please provide a repo where we can replicate this? I just created this one using your gemfiles and just disabled a couple of gems that I won’t have the time to setup. Everything works fine here and created that one from scratch. Even if you can replicate the error on that repo, that’d be awesome.