-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrap initialization in reloader.to_prepare to avoid autoload deprecation warning in some cases #349
Conversation
…ion warning in some cases
5f6c548
to
8f8dd7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, looks very reasonable to me, but I'm not sure I understand rails loading well enough to approve it with confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, and since CI passes with Rails 5.1/5.2/6.0, I'm comfortable merging this.
I'm running into the following error when trying to build Hyrax's docker images.
This is happening when I played with different forms and the only I was seeing as working were |
Sorry I'm off on Fridays so just going through all my messages and alerts and getting to this. While we've already reverted the change thinking we didn't have the bandwidth... For future reference, I think the answer would/could have been that the thing in your local
|
My Rails 6.1.3.2 app that uses
qa
gem has this deprecation warning on startup in development mode:/Users/jrochkind/code/scihist_digicoll/config/environment.rb:5
is justRails.application.initialize!
.I haven't been able to reproduce this in a new fresh Rails 6.1.3.2 app -- I'm not sure what settings in my actual app are triggering this warning, when I can't get a fresh app too. I've spent some time trying.
However, it seems like this is a legit problem, that could affect other apps, and should be fixed. Here is the Rails Autoloading and Reloading Constants Guide.
The small change in this PR eliminates the deprecation warning for me. And I believe is appropriate for Rails.
Other possible changes could have been:
extend ActiveSupport::Autoload
in various places (they've been there for a long time), to opt-in to Rails autoloading for classes that would ordinarily not be auto-loaded. (I think engine classes are not autoloaded by default at all). i think that's the root of the problem, and I'm not sure if it's really a good idea or necessary -- but seemed like a bigger change than I wanted to make for now.Those might actually make sense, but I was nervous to try to make more than the smallest change that seemed to resolve the problem, which this is.
I have also confirmed:
to_prepare
blockRails.application.reloader
API was introduced in Rails 5.0.0, which is the oldest version of Rails that this gem currently supports, so it is available in all versions of this gem.The only thing that makes me nervous is I don't understand why I can't reproduce in stock from scratch app. Still, I think this change should be harmless and appropriate and will fix this problem -- unless someone would prefer we go removing all the
extend ActiveSupport::Autoload
sprinkled throughout the gem, which may actually be a more fundamental fix.