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

Add extension paths before initialize_cache #71

Conversation

gsmendoza
Copy link
Contributor

@gsmendoza gsmendoza commented Jun 1, 2022

solidus_support v0.9.0, released on May 26, 2022, included a commit that fixes
the load order of adding extension paths. See
202e77c.
The commit depends on the initialize_dependency_mechanism Rails initializer
(https://github.com/rails/rails/blob/127dd06df66552dd272eea7832f8bb205cf6fd01/railties/lib/rails/application/bootstrap.rb#L68).
However, that initiliazer was removed in Rails 7.0.3
(rails/rails@0375657).

The extension paths initializer has been updated to run before
initialize_cache. initialize_cache runs 1) after the Solidus engines have
already loaded BUT 2) before Rails has added the paths to $LOAD_PATH.
Normally, it would be sufficient to run the initializer before the
set_load_path initializer. However, external gems such as Deface may also
change the load paths before set_load_path. To ensure that our
extension paths are not affected by those gems, we work around those gems by
adding our paths before initialize_cache, which is the Rails initializer
called before set_load_path.

References

Testing

Tested on SolidusPaypalCommercePlatform:

solidus_support v0.9.0, released on May 26, 2022, included a commit that fixes
the load order of adding extension paths. See
solidusio@202e77c.
The commit depends on the `initialize_dependency_mechanism` Rails initializer
(https://github.com/rails/rails/blob/127dd06df66552dd272eea7832f8bb205cf6fd01/railties/lib/rails/application/bootstrap.rb#L68).
However, that initiliazer was removed in Rails 7.0.3
(rails/rails@0375657).

The extension paths initializer has been updated to run before
`initialize_cache`. `initialize_cache` runs 1) after the Solidus engines have
already loaded BUT 2) before Rails has added the paths to `$LOAD_PATH`.
Normally, it would be sufficient to run the initializer before the
`set_load_path` initializer. However, external gems such as Deface may also
change the load paths before `set_load_path`. To ensure that our
extension paths are not affected by those gems, we work around those gems by
adding our paths before `initialize_cache`, which is the Rails initializer
called before `set_load_path`.

References
----------

* `bin/rails initializers` - Shows list of active initializers
* List of Rails initializers: https://guides.rubyonrails.org/configuring.html#initializers
* Engine paths configuration - See Paths section in https://api.rubyonrails.org/v7.0.3/classes/Rails/Engine.html.
@gsmendoza gsmendoza marked this pull request as ready for review June 1, 2022 09:32
@gsmendoza gsmendoza force-pushed the gsmendoza/eng-344-fix-actionviewmissingtemplate-errors-on branch from e4675a9 to 12c970e Compare June 1, 2022 09:32
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @gsmendoza!

@gsmendoza gsmendoza merged commit ee071bb into solidusio:master Jun 1, 2022
MassimilianoLattanzio added a commit to sdtechdev/solidus_support that referenced this pull request May 10, 2024
In solidusio#65 and solidusio#71
they changed how the engine i loaded using the Rails initializers.
This updates causes some issues when using Rails <6.1 because
the initializers are totally different. The solution is to load
the extension outside of the initializer block until we use Rails 6.1
or newer version.

Ref: solidusio#73.
MassimilianoLattanzio added a commit to sdtechdev/solidus_support that referenced this pull request May 10, 2024
In solidusio#65 and solidusio#71
they changed how the engine is loaded using the Rails initializers.
This updates causes some issues when using Rails < 6.1 because
the initializers are totally different. The solution is to load
the extension outside of the initializer block until we use Rails 6.1
or newer version.

Ref: solidusio#73.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants