Skip to content

Spring uses AS::Dependencies.mechanism= #649

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

Closed
fxn opened this issue Aug 22, 2021 · 7 comments · Fixed by #651 or #652
Closed

Spring uses AS::Dependencies.mechanism= #649

fxn opened this issue Aug 22, 2021 · 7 comments · Fixed by #651 or #652

Comments

@fxn
Copy link
Member

fxn commented Aug 22, 2021

The accessor ActiveSupport::Dependencies.mechanism is private and deleted in Rails 7.

Rails has only one way to enable or disable reloading: config.cache_classes. Spring should document it requires that to be false because it reloads, and verify the flag in an initializer for robustness.

@byroot
Copy link
Member

byroot commented Aug 24, 2021

Ah, I just noticed the same thing today when upgrading Rails and worked on a fix: #651

@fxn
Copy link
Member Author

fxn commented Aug 24, 2021

@byroot I see there is an additional occurrence in

ActiveSupport::Dependencies.mechanism = :require
.

I don't discard coming later and replacing all this with documentation. Spring has no business manipulating the configuration of the user at its will. That configuration has to be there before we bootstrap, and nobody is telling you what you can do after it.

@byroot
Copy link
Member

byroot commented Aug 24, 2021

Ah good catch. Sorry I didn't do a great job here, and just directly fixed the error I was seeing.

It's also unfortunate that the true acceptance tests don't run against rails edge, which would likely have caught this.

I agree spring probably shouldn't deal with that. But maybe it could make sense to do a new major version that requires Rails 7? Since it could assume Zeitwerk it might simplify thing. Just a thought.

@fxn
Copy link
Member Author

fxn commented Aug 24, 2021

I agree spring probably shouldn't deal with that. But maybe it could make sense to do a new major version that requires Rails 7? Since it could assume Zeitwerk it might simplify thing. Just a thought.

It's not really about Rails 7. In my view, it should just not do anything of this and be compatible with all versions. You document config.cache_classes must be false because Spring reloads. If you want to reload, that is config.cache_classes = false in Rails.

Then, the initializer aborts if the setting is not false.

@dhh
Copy link
Member

dhh commented Sep 8, 2021

Seems like this is still a problem. @byroot were you planning to have a look at this?

@dhh dhh reopened this Sep 8, 2021
@byroot
Copy link
Member

byroot commented Sep 8, 2021

If I find the time yes, but it might take a while.

@fxn
Copy link
Member Author

fxn commented Sep 8, 2021

I'll do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants