Redmine 5: RuntimeError when reloading Rails console
Added by Thomas Löber almost 2 years ago
Hi!
When I start a Rails console in development and at some point run a reload!
to reload changes I have just made to the source code, I get a RuntimeError
:
> rails console Loading development environment (Rails 6.1.7) irb(main):001:0> reload! Reloading... Traceback (most recent call last): 7: from config/initializers/30-redmine.rb:11:in `block in <top (required)>' 6: from lib/redmine/preparation.rb:163:in `prepare' 5: from lib/redmine/menu_manager.rb:251:in `map' 4: from lib/redmine/preparation.rb:164:in `block in prepare' 3: from lib/redmine/menu_manager.rb:321:in `push' 2: from lib/redmine/menu_manager.rb:403:in `add' 1: from lib/redmine/menu_manager.rb:386:in `add_at' RuntimeError (Child already added)
The source of the error is Redmine::Preparation.prepare
, which is called in this to_prepare
block in config/initializers/30-redmine.rb
:
Rails.application.config.to_prepare do I18n.backend = Redmine::I18n::Backend.new # Forces I18n to load available locales from the backend I18n.config.available_locales = nil Redmine::Preparation.prepare end
The reason for the error is that Rails.application.reloader.reload!
correctly runs the prepare
callbacks, but Redmine::Preparation.prepare
does not support being called multiple times.
Am I fundamentally doing something wrong or is this an issue that still needs to be fixed?
Thanks,
Thomas
Replies (1)
RE: Redmine 5: RuntimeError when reloading Rails console - Added by Thomas Löber almost 2 years ago
I have created Patch #38155 to fix the issue.
Thomas