Skip to content

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

Closed
@eliotsykes

Description

@eliotsykes

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions