Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load Rake tasks only once for command suggestions
Follow-up to rails#47208. `UnrecognizedCommandError` calls `printing_commands` to make "Did you mean?" suggestions. `printing_commands` calls `RakeCommand::rake_tasks`, which loads the Rake tasks if they have not been memoized. If the tasks have already been loaded by `RakeCommand::perform` (but not memoized by `RakeCommand::rake_tasks`), then the tasks will be loaded a second time. This can cause, for example, constant redefinition warnings if the task files define constants. Therefore, this commit memoizes the tasks from `RakeCommand::perform` before raising `UnrecognizedCommandError`.
- Loading branch information