Skip to content

Commit 7996fc4

Browse files
justin808claude
andcommitted
Fix duplicate rake task execution by removing explicit task loading
Rails Engine automatically loads all .rake files from lib/tasks/ directory via its run_tasks_blocks method. The explicit load calls in the rake_tasks block caused each task file to be loaded twice: 1. Once via explicit load in rake_tasks block (Railtie layer) 2. Once via automatic loading by Rails::Engine This resulted in tasks having duplicate action blocks, causing: - react_on_rails:assets:webpack to run webpack build twice - react_on_rails:generate_packs to run twice - react_on_rails:locale to compile locales twice The fix removes the explicit load calls and relies on Rails Engine's standard auto-loading behavior from lib/tasks/*.rake, which already works correctly for doctor.rake. Verified that all tasks (assets:webpack, generate_packs, locale, doctor) load correctly with exactly 1 action block each. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ae8b1b1 commit 7996fc4

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/react_on_rails/engine.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ def self.package_json_missing?
8383
ReactOnRails::ServerRenderingPool.reset_pool
8484
end
8585

86-
rake_tasks do
87-
load File.expand_path("../tasks/generate_packs.rake", __dir__)
88-
load File.expand_path("../tasks/assets.rake", __dir__)
89-
load File.expand_path("../tasks/locale.rake", __dir__)
90-
end
86+
# Rake tasks are automatically loaded from lib/tasks/*.rake by Rails::Engine
87+
# No need to explicitly load them here to avoid duplicate loading
9188
end
9289
end

0 commit comments

Comments
 (0)