solidusio / solidus_auth_devise

🔑 Devise authentication for your Solidus store.
http://solidus.io
BSD 3-Clause "New" or "Revised" License
53 stars 128 forks source link

Zeitwerk Issue on Rails 6.1 #210

Open jarednorman opened 3 years ago

jarednorman commented 3 years ago

Someone reported an issue over here where the Spree::User model wasn't present when installing Solidus. It was solved by returning to the classic autoloader. This suggests to me that we may have an issue with Zeitwerk loading in recent versions.

I've not investigated this any further, but didn't want to forget so I opened this issue.

mamhoff commented 1 year ago

I'm likely running into a related issue: Currently (Solidus main as of https://github.com/solidusio/solidus/commit/78d20c41b61c8fd3e708c3871030f4e6a5948628, solidus_auth_devise version 2.5.8) the sandbox can't find the backend sessions controller. This is the error when you try:

Started GET "/admin/" for 127.0.0.1 at 2023-06-12 15:37:29 +0200
  ActiveRecord::SchemaMigration Pluck (0.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Spree::Admin::RootController#index as HTML
Redirected to http://localhost:3000/admin/login
Completed 302 Found in 340ms (ActiveRecord: 0.8ms | Allocations: 530212)

Started GET "/admin/login" for 127.0.0.1 at 2023-06-12 15:37:29 +0200

ActionController::RoutingError (uninitialized constant Spree::Admin::UserSessionsController

      Object.const_get(camel_cased_word)
            ^^^^^^^^^^
Did you mean?  UserPasswordsController

            raise MissingController.new(error.message, error.name)
            ^^^^^):
bin/rails zeitwerk:check

results in

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/anselm/.gem/ruby/3.1.4/gems/solidus_paypal_commerce_platform-1.0.1/app/decorators/models
  /home/anselm/.gem/ruby/3.1.4/gems/solidus_auth_devise-2.5.8/lib/decorators/backend/controllers
  /home/anselm/.gem/ruby/3.1.4/gems/solidus_auth_devise-2.5.8/lib/controllers/backend/spree

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!

So somewhere, maybe in engine.rb or in some other initializer, we need to add those paths to zeitwerks autoload_paths.