-
Notifications
You must be signed in to change notification settings - Fork 341
Rails::Application
in Rails::Engine.descendants
causing undefined method 'root' error
during Spring v4.3.0 preloading
#737
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
Comments
After reinstalling the ruby version, reinstalling rvm, and switching over to rbenv, I still experienced the same issue. However, another developer on my team was successful in using Spring v4.3.0 with the same codebase on their machine. |
I just encountered this as well while updating an application to Rails 7.0.8.7. One similarity I notice is that I'm also still on Ruby 3.0 (3.0.1 in my case), and updating that to 3.1.7 seemed to avoid the issue as well. Unfortunately I can't update Ruby on my server just yet, so instead I've downgraded Spring to 4.2.1 for now. |
Spring v4.3.0, in combination with Ruby 3.0.7 and Rails 7, is causing an error that blocks the Rails start. Error: method_missing: undefined method root for Rails::Application:Class (NoMethodError) One solution could be to upgrade Ruby to 3.1.7, but that doesn't work on the latest Fedora 42 [1]. And upgrading to 3.2.z is not feasible due to some gems limiting Ruby versions to < 3.2 (safe-render, I think). External issues: [0] rails/spring#737 [1] rbenv/ruby-build#2529
Just for context: ActiveSupport patches I suspect that the native Ruby implementation yields a slightly different result where one does return |
Spring v4.3.0, in combination with Ruby 3.0.7 and Rails 7, is causing an error that blocks the Rails start. Error: method_missing: undefined method root for Rails::Application:Class (NoMethodError) One solution could be to upgrade Ruby to 3.1.7, but that doesn't work on the latest Fedora 42 [1]. And upgrading to 3.2.z is not feasible due to some gems limiting Ruby versions to < 3.2 (safe-render, I think). External issues: [0] rails/spring#737 [1] rbenv/ruby-build#2529
Spring v4.3.0, in combination with Ruby 3.0.7 and Rails 7, is causing an error that blocks the Rails start. Error: method_missing: undefined method root for Rails::Application:Class (NoMethodError) One solution could be to upgrade Ruby to 3.1.7, but that doesn't work on the latest Fedora 42 [1]. And upgrading to 3.2.z is not feasible due to some gems limiting Ruby versions to < 3.2 (safe-render, I think). External issues: [0] rails/spring#737 [1] rbenv/ruby-build#2529
Observation:
When using Spring v4.3.0 with Rails v7.1.5.1, the following error is encountered during preloading when starting the rails console:
The error occurs in the Spring preloader, specifically when iterating through
Rails::Engine.descendants
in the Spring application boot process (see line 127 in the Spring code).Debugging
The following modification to the Spring preloader code reveals which engine(s) do not respond to the root method:
Running this revealed the following output:
Cause
The issue arises because
Rails::Application
is part ofRails::Engine.descendants
, but it does not respond to the root method as other Rails engines do. This results in theNoMethodError
when Spring tries to call root on it.Suggested Solution
Modify the Spring preloader code to check if the engine responds to root before calling it. Specifically, update the block that iterates through
Rails::Engine.descendants
as follows:This ensures that
Rails::Application
(and any other engines that do not respond to root) are safely excluded from the root method call.The text was updated successfully, but these errors were encountered: