@@ -80,6 +80,8 @@ def load_rails_application(environment_load: false, eager_load: false, app_root:
8080 def load_rails_engines
8181 return if engines . empty?
8282
83+ normalize_eager_load_paths_configuration!
84+
8385 with_rails_application do
8486 run_initializers
8587
@@ -110,7 +112,7 @@ def load_engines_in_zeitwerk_mode
110112 autoloader = Zeitwerk ::Loader . new
111113
112114 engines . each do |engine |
113- engine . config . eager_load_paths . each do |path |
115+ engine . config . all_eager_load_paths . each do |path |
114116 # Zeitwerk only accepts existing directories in `push_dir`.
115117 next unless File . directory? ( path )
116118 # We should not add directories that are already managed by a Zeitwerk loader.
@@ -131,7 +133,7 @@ def load_engines_in_classic_mode
131133 # We can't use `Rails::Engine#eager_load!` directly because it will raise as soon as it encounters
132134 # an error, which is not what we want. We want to try to load as much as we can.
133135 engines . each do |engine |
134- engine . config . eager_load_paths . each do |load_path |
136+ engine . config . all_eager_load_paths . each do |load_path |
135137 Dir . glob ( "#{ load_path } /**/*.rb" ) . sort . each do |file |
136138 require_dependency file
137139 end
@@ -179,6 +181,19 @@ def engines
179181 . reject { |engine | gem_in_app_dir? ( project_path , engine . config . root . to_path ) }
180182 end
181183
184+ # Rails 7.2 renamed `eager_load_paths` to `all_eager_load_paths`, which maintains the same original functionality.
185+ # The `eager_load_paths` method still exists, but doesn't return all paths anymore and causes Tapioca to miss some
186+ # engine paths. The following commit is the change:
187+ # https://github.com/rails/rails/commit/ebfca905db14020589c22e6937382e6f8f687664
188+ #
189+ # Here we make sure that the new `all_eager_load_paths` is always defined for every Rails version below 7.2, so
190+ # that we can use it everywhere
191+ def normalize_eager_load_paths_configuration!
192+ return if Rails ::VERSION ::MAJOR >= 7 && Rails ::VERSION ::MINOR >= 2
193+
194+ engines . each { |e | e . config . all_eager_load_paths = e . config . eager_load_paths }
195+ end
196+
182197 sig { params ( path : String ) . void }
183198 def safe_require ( path )
184199 require path
0 commit comments