graphql-devise / graphql_devise

GraphQL interface on top devise_token_auth
MIT License
199 stars 42 forks source link

Uninitialized constant GraphqlDevise #216

Closed mengqing closed 2 years ago

mengqing commented 2 years ago

Getting the following error

uninitialized constant GraphqlDevise (NameError)

ActionDispatch::Routing::Mapper.include(GraphqlDevise::RouteMounter)
                                        ^^^^^^^^^^^^^

Possibly related to https://github.com/graphql-devise/graphql_devise/pull/209

If I move ActionDispatch::Routing::Mapper.include(GraphqlDevise::RouteMounter) to the end of the file then it works

00dav00 commented 2 years ago

Hi @mengqing , that is strange, could you post a gist with your Gemfile please? By the time this line is reached, zeitwerk must have loaded the gem module already.

dominikklein commented 2 years ago

I have the same error:

.rvm/gems/ruby-3.1.0/bundler/gems/graphql_devise-c1f730d227a4/lib/graphql_devise.rb:23:in `<main>': uninitialized constant GraphqlDevise (NameError)
web.1  | Did you mean?  GraphQL

https://gist.github.com/dominikklein/9152d9e5c16532202dd49f4223e9cab5

00dav00 commented 2 years ago

@dominikklein thanks for the gist, do you think you can add full backtrace of the error to it please? Also:

I noticed you are referencing the GH repo directly, that will make bundler use the master branch instead of a published version of the gem. Any particular reason for this?

dominikklein commented 2 years ago

I think i had some problems with the versions for "devise_token_auth" without fetching it directly from GH.

Now i tested it both gems again without the GH and the installation is working. And also the error is gone, so i think for me it's fine now.

But here the additional information. When i add the GH again the error is present, maybe some caching? I'm in my local development envoirment and eager loading should not be active in this case.

Here the full traceback:

web.1  | .rvm/gems/ruby-3.1.1/bundler/gems/graphql_devise-c1f730d227a4/lib/graphql_devise.rb:23:in `<main>': uninitialized constant GraphqlDevise (NameError)
web.1  | Did you mean?  GraphQL
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler/runtime.rb:55:in `each'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler/runtime.rb:55:in `block in require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler/runtime.rb:44:in `each'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler/runtime.rb:44:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bundler-2.3.3/lib/bundler.rb:176:in `require'
web.1  |    from Projects/knowlydesk-playground/config/application.rb:19:in `<main>'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/railties-6.1.4.7/lib/rails/commands/server/server_command.rb:138:in `block in perform'
web.1  |    from <internal:kernel>:90:in `tap'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/railties-6.1.4.7/lib/rails/commands/server/server_command.rb:135:in `perform'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/railties-6.1.4.7/lib/rails/command/base.rb:69:in `perform'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/railties-6.1.4.7/lib/rails/command.rb:48:in `invoke'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/railties-6.1.4.7/lib/rails/commands.rb:18:in `<main>'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from .rvm/gems/ruby-3.1.1/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web.1  |    from Projects/XYZ-playground/bin/rails:4:in `<main>'
00dav00 commented 2 years ago

Thanks for the insights @dominikklein , will try to replicate in local. Good to know your project works now.

00dav00 commented 2 years ago

@dominikklein I'm unable to reproduce this in my local forcing lazy loading. Is XYZ-playground in a public repo? If it is I think it could be quite useful to have the url since it's setup is triggering the problem already.

mcelicalderon commented 2 years ago

@dominikklein if spring is not running, you could try removing bootsnap's cahce as I see you are using it. For that you can stop the app and run rm -rf tmp/cache/

00dav00 commented 2 years ago

@mengqing this problem was addressed with #220 , I'm closing this issue for now.