I swear I've read the docs and I think I have a basic understanding of the principles, but I can't for the life of me figure out where I'm loading these constants inappropriately.
I'm working to upgrade an app that was originally Rails 5.2
I'm getting this warning when I run RSpec, a server, a local console, etc.
DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper, EventsHelper, FontAwesome::Rails::IconHelper, DeviseHelper, ErrorHandler, and ApplicationController.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
Here are the constants that are being inappropriately autoloaded:
I've looked for instances where I might be calling
require for these constants, but found none. I especially focused on my initializers.
I've run (and read through)
bin/rails zeitwerk:check without any obvious hints. I see these instances getting loaded as expected:
[email protected]: constant ApplicationHelper loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/helpers/application_helper.rb
[email protected]: constant EventsHelper loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/helpers/events_helper.rb
[email protected]: constant FontAwesome::Rails::IconHelper loaded from file /Users/ckragt/.rvm/gems/ruby-2.7.0/gems/font-awesome-rails-22.214.171.124/app/helpers/font_awesome/rails/icon_helper.rb
[email protected]: constant DeviseHelper loaded from file /Users/ckragt/.rvm/gems/ruby-2.7.0/gems/devise-4.7.3/app/helpers/devise_helper.rb
[email protected]: constant ErrorHandler loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/controllers/concerns/error_handler.rb
[email protected]: autoload set for ApplicationController, to be loaded from /Users/ckragt/ruby/filterbuildscheduler/app/controllers/application_controller.rb
I am using Spring and Binstub (both updated to latest versions).
Here's the top of my
# frozen_string_literal: true
# Pick the frameworks you want:
# require "active_storage/engine"
# require 'action_mailbox/engine'
# require 'action_text/engine'
# require 'action_cable/engine'
# require 'rails/test_unit/railtie'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
Any ideas of where else I should look?
Turns out this seems to be related to
Someone else shared my frustration at the warning message and asked for more help tracing the issue.
One response recommended putting
pp caller_locations at the top of one of the files that was being autoloaded. Doing this gave me a traceback I could use. That's when I noticed that
rails_admin appeared as a path in each one.
I noticed I already had a huge list of
require statements in
For a lark, I commented all of them out, then ran a RSpec test. My warning message suddenly got SUPER long with a bunch more instances:
DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper, EventsHelper, FontAwesome::Rails::IconHelper, DeviseHelper, ErrorHandler, ApplicationController, ApplicationRecord, User, Event, Registration, Location, Technology, Component, Part, Material, Supplier, Count, Inventory, ExtrapolateComponentPart, ExtrapolateMaterialPart, ExtrapolateTechnologyComponent, ExtrapolateTechnologyPart, and ExtrapolateTechnologyMaterial.
So I decided to add in my previous instances:
...to my already long list, my warning message, all of them but the
FontAwesome::Rails::IconHelper goes away. I think I can get that one too, if I can just figure out the correct filepath.