7

I'm trying to understand the deprecation warning:

DEPRECATION WARNING: Initialization autoloaded the constants 
ActionText::ContentHelper and ActionText::TagHelper.

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 
ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module 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.

Check the "Autoloading and Reloading Constants" guide to learn more about how
Rails autoloads and reloads.
 (called from <top (required)> at 
/home/keith/development/pciapp/config/environment.rb:5)

What does this deprecation warning mean and how do I resolve it?

karns
  • 5,391
  • 8
  • 35
  • 57
  • Both https://stackoverflow.com/a/66427161/5354137 as well as https://stackoverflow.com/a/75952670/5354137 show debugging strategies that will help solve this. – Sixtyfive Aug 25 '23 at 08:03

2 Answers2

5

A bit of sleuthing revealed two sources of this deprecation warning in my Rails 6.1 app.

  1. I referenced ActionMailer::Base in a couple of initializers. Based on the suggestion in the Rails Guides (https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration), I decided to move all those references to environment.rb.

  2. The same deprecation error was also apparently being generated by the mailgun-ruby gem v 1.2.3. It appears the deprecation warning has been fixed in v 1.2.4.

JJL
  • 116
  • 7
  • Instead of using ActionMailer::Base in your initializer, use Rails.configuration.action_mailer instead – Mike Glenn May 29 '21 at 19:34
  • This bit of sleuthing you did... can you tell me how you were able to trace the deprecation message to the source? – Jason Perrone Jun 15 '21 at 12:54
  • Just to expand on this a bit: I was able to solve the initalizer problem by defining it in `lib/`, and then requiring it in a config (I used `development.rb`) and then registering it normally in the config block via `ActionMailer::Base#register_interceptor`. – David Gay Jun 16 '21 at 14:12
  • @JasonPerrone I basically commented out tons of gems and code until I no longer saw the deprecation warning. Then I started adding things back in to see if that fixed it. I got super confused at one point until I realized I was seeing unexpected behavior because there were actually multiple sources of the deprecation warning in my app. Hope that helps! – JJL Jun 16 '21 at 14:17
0

it was an issue in rails 6.0.0 https://github.com/rails/rails/issues/36546 updating to rails 6.0.1 should fix this

Mshka
  • 1,798
  • 1
  • 10
  • 19
  • @karns can you post the whole log, it's possible another gem your are using is causing this and it would need an update too – Mshka Apr 12 '21 at 18:42
  • Yes, I'll update the question. Note that it happens when I run my rspec test suite. – karns Apr 12 '21 at 18:44
  • Also, I upgraded to the newest rails version, still the same. – karns Apr 12 '21 at 18:46
  • Following. Experiencing the same issue in Rails 6.1. Only seeing it when I run my test suite and/or run guard. – JJL Apr 23 '21 at 17:32