Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetupRequired in rails app on Rails.application.initialize! #239

Closed
jackm767 opened this issue Nov 22, 2022 · 5 comments
Closed

SetupRequired in rails app on Rails.application.initialize! #239

jackm767 opened this issue Nov 22, 2022 · 5 comments

Comments

@jackm767
Copy link

jackm767 commented Nov 22, 2022

Hello I have a fairly straight forward rails app here which is failing rails zeitwerk:check. It seems to happen upon the app initialization, but I cannot find any documentation on how to fix this. I've tried calling setup in application.rb above and below the app initalization, but neither seems to fix it. Apologies if this is a repeat issue, it does not seem to be?

jm@Jacks-MBP sp % rails zeitwerk:check
rails aborted!
Zeitwerk::SetupRequired: please, finish your configuration and call Zeitwerk::Loader#setup once all is ready
/Users/jm/code/sp/config/environment.rb:6:in `<main>'
/Users/jm/code/sp/bin/rails:5:in `<top (required)>'
/Users/jm/code/sp/bin/spring:10:in `require'
/Users/jm/code/sp/bin/spring:10:in `block in <top (required)>'
/Users/jm/code/sp/bin/spring:7:in `tap'
/Users/jm/code/sp/bin/spring:7:in `<top (required)>'
Tasks: TOP => zeitwerk:check => environment
(See full trace by running task with --trace)
jm@Jacks-MBP sp % rails zeitwerk:check --trace
** Invoke zeitwerk:check (first_time)
** Invoke environment (first_time)
** Execute environment
rails aborted!
Zeitwerk::SetupRequired: please, finish your configuration and call Zeitwerk::Loader#setup once all is ready
/Users/jm/.rvm/gems/ruby-2.7.6/gems/zeitwerk-2.6.6/lib/zeitwerk/loader/eager_load.rb:12:in `block in eager_load'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/zeitwerk-2.6.6/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/zeitwerk-2.6.6/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/autoloaders.rb:30:in `each'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/application.rb:517:in `eager_load!'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/contentful_rails-0.5.0/lib/contentful_rails/engine.rb:39:in `block in <class:Engine>'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `instance_exec'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `run'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/initializable.rb:61:in `block in run_initializers'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `each'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `call'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/Users/jm/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/initializable.rb:60:in `run_initializers'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/application.rb:391:in `initialize!'
/Users/jm/code/sp/config/environment.rb:6:in `<main>'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in `block in require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:299:in `load_dependency'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in `require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/application.rb:367:in `require_environment!'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/command.rb:50:in `invoke'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/railties-6.1.7/lib/rails/commands.rb:18:in `<main>'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/jm/code/sp/bin/rails:5:in `<top (required)>'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/Users/jm/.rvm/gems/ruby-2.7.6/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/jm/code/sp/bin/spring:10:in `require'
/Users/jm/code/sp/bin/spring:10:in `block in <top (required)>'
/Users/jm/code/sp/bin/spring:7:in `tap'
/Users/jm/code/sp/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Tasks: TOP => zeitwerk:check => environment
@fxn
Copy link
Owner

fxn commented Nov 22, 2022

I see this uncovered a latent issue in cotentful_rails, because it eager loads the whole application when things are not yet ready to eager load, here.

There is a flag to disable that according to these docs.

They could eager load in a to_prepare block.

@fxn fxn closed this as completed Nov 22, 2022
@fxn
Copy link
Owner

fxn commented Nov 22, 2022

I opened contentful/contentful_rails#61.

@jackm767
Copy link
Author

Thank you!

@fxn
Copy link
Owner

fxn commented Nov 22, 2022

I see that repo does not seem to have a lot of activity. If you needed to fork it and wonder how to patch the engine, please just tell me, I'd be glad to help.

@jackm767
Copy link
Author

I think it's okay with not eager loading, but if issues arise I'll give it a shot and let you know. Thank you for your help and time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants