solidusio / solidus_support

Common runtime helpers for Solidus extensions.
BSD 3-Clause "New" or "Revised" License
9 stars 23 forks source link

Solidus Support 0.9 breaks loading of Solidus Auth Devise in Rails 5.2 (and possibly other extensions) #73

Closed Noah-Silvera closed 2 years ago

Noah-Silvera commented 2 years ago

A change introduced Solidus Support 0.9 #65 causes the solidus auth devise controllers not to be eager loaded on boot in rails 5.2

This results in this error message when trying to access the solidus admin. This is a failure to load a controller constant from solidus_auth_devise

Screen Shot 2022-07-21 at 13 21 25PDT

This can be reproduced in an app with the following setup

Rails 5.2.8.1 Solidus 2.11.17 Solidus Support 0.9.0 Solidus Auth Devise 2.5.4

Here is a repository with a pre-setup app to reproduce it. https://github.com/Noah-Silvera/solidus-support-0.9-engine-bug

If you comment out this initializer block,

       # initializer "#{name}_#{engine}_paths", before: :initialize_cache do
          if SolidusSupport.send(:"#{engine}_available?")
            paths['app/controllers'] << "lib/controllers/#{engine}"
            paths['app/views'] << "lib/views/#{engine}"
          end
       # end

The error is resolved.

I suspect this is due to a different in code loading in Rails 5 and Rails 6, which introduced zeitwerk, or a change in how/when railties processes initializers.

gsmendoza commented 2 years ago

Hi @Noah-Silvera ! I was able to confirm your issue, and it seems I was able to work around it by downgrading SolidusSupport to 0.8.1. Please see https://github.com/Noah-Silvera/solidus-support-0.9-engine-bug/pull/1.

Is there a reason you need to use SolidusSupport 0.9.0 on your Rails 5.2 app? Based on https://endoflife.date/rails and https://guides.rubyonrails.org/maintenance_policy.html, support for Rails 5.2 has already ended. Thus, it's not likely we'll update this gem to support Rails 5.2.

Noah-Silvera commented 2 years ago

Hey @gsmendoza!

Yeah, it can definitely be worked around by downgrading to 0.8.1! I was able to workaround that on my app. And you are totally right, rails 5.2 is at end of life! So that's super fair not to update this gem. Just wanted to point the issue out, feel free to close this!

Noah-Silvera commented 2 years ago

I appreciate you looking into this and confirming this!

gsmendoza commented 2 years ago

@Noah-Silvera Good to hear you were able to work around the issue. I'll be closing this issue.