prograils / lit

rails i18n web interface
MIT License
298 stars 71 forks source link

Conflict with Zeitwerk on migration rails 6>7 #188

Open ExperienciasPeru opened 2 years ago

ExperienciasPeru commented 2 years ago

Regards.

Currently I'm on a migration process, but I cannot find myself a way through the current problem, somehow Lit works perfectly with redis on my 'local' environment (literal clone from 'development'), but when I run it from the Development server, it just simply break because Zeitwerk cannot load the controller concerns (output below).

First I want to list exactly what changes I've made and the environment details:

Ruby 2.7.6 > 3.1.2

  • ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
  • ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] Rails 6.1.5 > 7.0.3.1 Yes, I updated all the Gemset automatically with bundler, will upload if required.

About the server environment ('local' too):

RVM 1.29.12 (latest) Debian 10 (Buster) Nginx 1.14.2 Phusion Passenger(R) 6.0.14

Now, I like to always try a fresh install before making a ticket, if this is irrelevant, please move down to the 'Now my case' section.

$ rails new lit_test $ cd lit_test -> remove redis cause Lit installer ALWAYS append it and gives conflict with duplicated gem, I would recommend to add a validator, but this ticket is not about that. $ nano Gemfile $ bundle install $ bundle exec rails g lit:install

/.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/lib/lit.rb:56:in 'check_if_table_exists': uninitialized constant Lit::Locale (NameError)
Lit::Locale.table_exists?
^^^^^^^^
from /.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/lib/lit.rb:29:in 'init'
from /lit_test/config/initializers/lit.rb:62:in '<main>'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:667:in 'load'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:667:in 'block in load_config_initializer'
from /.rvm/gems/ruby-3.1.2/gems/activesupport-7.0.4/lib/active_support/notifications.rb:208:in 'instrument'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:666:in 'load_config_initializer'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:620:in 'block (2 levels) in <class:Engine>'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:619:in 'each'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:619:in 'block in <class:Engine>'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:32:in 'instance_exec'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:32:in 'run'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:61:in 'block in run_initializers'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:228:in 'block in tsort_each'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:350:in 'block (2 levels) in each_strongly_connected_component'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:422:in 'block (2 levels) in each_strongly_connected_component_from'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:431:in 'each_strongly_connected_component_from'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:421:in 'block in each_strongly_connected_component_from'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:50:in 'each'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:50:in 'tsort_each_child'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:415:in 'call'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:415:in 'each_strongly_connected_component_from'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:349:in 'block in each_strongly_connected_component'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:347:in 'each'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:347:in 'call'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:347:in 'each_strongly_connected_component'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:226:in 'tsort_each'
from /.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tsort.rb:205:in 'tsort_each'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/initializable.rb:60:in 'run_initializers'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/application.rb:372:in 'initialize!'
from /lit_test/config/environment.rb:5:in '<main>'
from /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
from /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
from /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in 'require'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/application.rb:348:in 'require_environment!'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/command/actions.rb:28:in 'require_environment!'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/command/actions.rb:15:in 'require_application_and_environment!'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands/generate/generate_command.rb:21:in 'perform'
from /.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor/command.rb:27:in 'run'
from /.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor/invocation.rb:127:in 'invoke_command'
from /.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor.rb:392:in 'dispatch'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/command/base.rb:87:in 'perform'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/command.rb:48:in 'invoke'
from /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands.rb:18:in '<main>'
from /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
from /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
from bin/rails:4:in '<main>'

When I exec the Zeitwerk validation: $ rails zeitwerk:check --trace


** Invoke zeitwerk:check (first_time)
** Invoke environment (first_time)
** Execute environment
rails aborted!
NameError: uninitialized constant Lit::Locale
Lit::Locale.table_exists?
   ^^^^^^^^

/.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/lib/lit.rb:56:in check_if_table_exists' /.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/lib/lit.rb:29:ininit' /lit_test/config/initializers/lit.rb:62:in <main>' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:667:inload' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/engine.rb:667:in `block in load_config_initializer' [...]

Then I prevent the init of Lit so I can debug the trace (comment line 62 on initializer) and re execute the validation, same error (NameError: uninitialized constant Lit::Locale)

So I added the eager_load_path manually to the application.rb:

`config.eager_load_paths << "#{Gem.loaded_specs['lit'].full_gem_path.to_s}/app/controllers/lit/concerns" `

Then revalidate:
> $ rails zeitwerk:check --trace

Invoke zeitwerk:check (first_time) Invoke environment (first_time) Execute environment Execute zeitwerk:check Hold on, I am eager loading the application. rails aborted! NameError: uninitialized constant Lit::Concerns

module Lit::Concerns::RequestInfoStore ^^^^^^^^^^ Did you mean? Concurrent /.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/app/controllers/lit/concerns/request_info_store.rb:1:in <main>' /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:inrequire' /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:inrequire' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:in const_get' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:incget' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:239:in block (2 levels) in eager_load' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:41:inblock in ls' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:in each' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:inls' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:234:in block in eager_load' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:insynchronize' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:in eager_load' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:ineach' /.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:in eager_load_all' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/tasks/zeitwerk.rake:5:inblock in

' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/tasks/zeitwerk.rake:39:in block (2 levels) in <main>' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:inblock in execute' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in each' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:inexecute' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in block in invoke_with_call_chain' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:insynchronize' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in invoke_with_call_chain' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:ininvoke' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in invoke_task' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:inblock (2 levels) in top_level' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in each' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:inblock in top_level' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in run_with_threads' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:intop_level' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in block (2 levels) in perform' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:instandard_exception_handling' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in block in perform' /.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:inwith_application' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in perform' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/command.rb:51:ininvoke' /.rvm/gems/ruby-3.1.2/gems/railties-7.0.4/lib/rails/commands.rb:18:in <main>' /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:inrequire' /.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' bin/rails:4:in
' Tasks: TOP => zeitwerk:check


At this point, I understand there's a clear incompatibility with Zeitwerk loader and Lit.. BUT.

# Now my case

When I grab my whole RoR6 project and make a refactor over a RoR7 fresh install, it actually doesn't break on local environment, because I'm taking the RoR6 database and updating my internal models as needed, it doesn't even raise any error or anything, just a deprecation log per record found:

`DEPRECATION WARNING: TimeWithZone#to_s(:db) is deprecated. Please use TimeWithZone#to_fs(:db) instead. (called from block (2 levels) in __<dir>__rvm_gems_ruby_______gems_lit_______app_views_lit_localization_keys__localizations_list_html_erb__1342166221744186634_88880 at /.rvm/gems/ruby-3.1.2/gems/lit-1.1.6/app/views/lit/localization_keys/_localizations_list.html.erb:49)`

And the translations are loading wonderfully, BUT the config.eager_load is disabled for the local and development environments, and thats whats making me noise, I need it active for production, when I push the Refactored project (again, working 100% in local) to the development server, passenger gives me the same old fresh-install-no-refactor error:

uninitialized constant Lit::Locale

Lit::Locale.table_exists?
   ^^^^^^^^ (NameError)

I don't know what could it be, I made no software changes or updates on my local/development servers, they are exact clones, I even made a fresh install on both of them (I made a script for it), but I cannot make it work on the development server :/

If I'm missing some step or dependencies, I'm ignorant about it.

Thank you for checking on this, will update if I find a workaround.

-----
Post-data
1: In my RoR6 install, the autoloader is set to :classic, but RoR7 removes this option and forces Zeitwerk to the framework, and yes, my refactored-working-local install is working with zeitwerk not with classic, gives me the concern warning but still works. 
2: rvm is not at root, just removed the home dir from the output.
3: This gem is a time saver, I hope it gets into stable soon.
mlitwiniuk commented 2 years ago

@ExperienciasPeru Could you please check with gem from github, from master branch?

ExperienciasPeru commented 2 years ago

@mlitwiniuk Just did it, results attached.

Standard on rails init.

Using lit 1.1.6 from https://github.com/prograils/lit (at master@dc11ab3)

rails aborted!
NameError: uninitialized constant Lit::Locale
Lit::Locale.table_exists?
^^^^^^^^
/var/www/r3r7/dev/config/initializers/lit.rb:62:in `<main>'
/var/www/r3r7/dev/config/environment.rb:5:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

Lit.init commented, eager_load automatic.

** Invoke zeitwerk:check (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute zeitwerk:check
Hold on, I am eager loading the application.

WARNING: The following directories will only be checked if you configure
them to be eager loaded:

  /home/webmaster/.rvm/gems/ruby-3.1.2/bundler/gems/lit-dc11ab341552/app/controllers/lit/concerns

You may verify them manually, or add them to config.eager_load_paths
in config/application.rb and run zeitwerk:check again.

Otherwise, all is good!

Lit.init commented, manual eager_load from application.rb

** Invoke zeitwerk:check (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute zeitwerk:check
Hold on, I am eager loading the application.
rails aborted!
NameError: uninitialized constant Lit::RequestKeysStore

  include Lit::RequestKeysStore
             ^^^^^^^^^^^^^^^^^^
Did you mean?  RequestInfoStore
/var/www/r3r7/dev/app/controllers/application_controller.rb:7:in `<class:ApplicationController>'
/var/www/r3r7/dev/app/controllers/application_controller.rb:1:in `<main>'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
/var/www/r3r7/dev/app/controllers/admin_controller.rb:1:in `<main>'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:in `const_get'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:in `cget'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:239:in `block (2 levels) in eager_load'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:41:in `block in ls'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:in `each'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:in `ls'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:234:in `block in eager_load'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:in `synchronize'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:in `eager_load'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:in `each'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:in `eager_load_all'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/tasks/zeitwerk.rake:5:in `block in <main>'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/tasks/zeitwerk.rake:39:in `block (2 levels) in <main>'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/webmaster/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/command.rb:51:in `invoke'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/railties-7.0.3.1/lib/rails/commands.rb:18:in `<main>'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/webmaster/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => zeitwerk:check
Kulgar commented 2 years ago

Hey, could this error be related to this deprecation warning I get:

DEPRECATION WARNING: Initialization autoloaded the constants Lit::Base, Lit::Locale, Lit::Localization, and Lit::LocalizationKey.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload Lit::Base, for example,
the expected changes won't be reflected in that stale Class object.

These autoloaded constants have been unloaded.

In order to autoload safely at boot time, please wrap your code in a reloader
callback this way:

    Rails.application.reloader.to_prepare do
      # Autoload classes and modules needed at boot time here.
    end

That block runs when the application boots, and every time there is a reload.
For historical reasons, it may run twice, so it has to be idempotent.

What do you think?

istana commented 1 year ago

I had the same issue and adding to_prepare block should help:

# Initialize lit
if Rails.env.staging? || Rails.env.production?
  Rails.application.reloader.to_prepare do
    Lit.init
  end
end