solidusio / solidus_support

Common runtime helpers for Solidus extensions.
BSD 3-Clause "New" or "Revised" License
9 stars 23 forks source link

Add extension paths before `initialize_cache` #71

Closed gsmendoza closed 2 years ago

gsmendoza commented 2 years ago

solidus_support v0.9.0, released on May 26, 2022, included a commit that fixes the load order of adding extension paths. See https://github.com/solidusio/solidus_support/commit/202e77c2d7887ee1edb7bf352b5a942e71b5176c. 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 (https://github.com/rails/rails/commit/0375657ce0fc16bda1d61e2fbf971743b4463c42).

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: