Skip to content
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

Initializers and react-rails gem placement in Gemfile suspect load order issue with after: :load_config_initializers option #1033

Closed
eliotsykes opened this issue Oct 3, 2019 · 3 comments

Comments

@eliotsykes
Copy link

eliotsykes commented Oct 3, 2019

I'm sorry to post an issue that is missing crucial evidence, but some debugging of a recent config loading bug makes me suspect that the react-rails railtie.rb may be modifying the load order of initializers, and preventing the values in Rails.application.config being as expected.

Whether this happens or not appears to be partly dependent on where in the Gemfile the react-rails gem is loaded. Placing react-rails at the very end of the Gemfile seems to help.

One suspect for changing the load order of initializers is the use of the after: :load_config_initializers option throughout react-rails' railtie.rb.

I couldn't find an explanation for this however Rails has removed one use of the after: :load_config_initializers option from its own active_support/railtie.rb with this comment:

Avoid to define an initializer after the load_config_initializers
This make the config/initializers run before the railties are loaded
what can break some configurations.
rails/rails@0a120a8

Some testing of commenting out the after: :load_config_initializers options in the react-rails railtie.rb did seem to alleviate the load order issue I was seeing when loading the react-rails gem.

I've not been able to get to the bottom of this yet I'm afraid, so I'm posting this here in the hope that other developers will encounter this, add their experience, and help resolve.

@eliotsykes eliotsykes changed the title Initializers and react-rails gem placement in Gemfile load order issue Initializers and react-rails gem placement in Gemfile suspect load order issue Oct 3, 2019
@eliotsykes eliotsykes changed the title Initializers and react-rails gem placement in Gemfile suspect load order issue Initializers and react-rails gem placement in Gemfile suspect load order issue with after: :load_config_initializers option Oct 3, 2019
@BookOfGreg
Copy link
Member

Sounds like an interesting discovery. It could be good to see how other popular rails gems tie in and change to modern good practice just as a matter of course, especially if we do end up showing this is causing an issue.

@alkesh26
Copy link
Collaborator

alkesh26 commented Nov 8, 2022

@eliotsykes Were you able to verify this issue again? Closing the issue for now.

@alkesh26 alkesh26 closed this as completed Nov 8, 2022
@eliotsykes
Copy link
Author

@alkesh26 Happy for this to be closed. Its been a while and I can't remember all the details I'm afraid. I think all the information and the workaround I found are detailed above.

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

No branches or pull requests

3 participants