spring
spring copied to clipboard
Ruby 3.1 / Rails 6.1 / Spring 4.3.0: "`initialize': Rails::Application is abstract, you cannot instantiate it directly. (RuntimeError)"
Hello,
GitHub actions is getting this error when trying to update a Rails 6.1 application to Spring 4.3.
/home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/railtie.rb:229:in `initialize': Rails::Application is abstract, you cannot instantiate it directly. (RuntimeError)
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/engine.rb:441:in `initialize'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/application.rb:12[9](https://github.com/diowa/ruby3-rails6-bootstrap-heroku/actions/runs/13832314292/job/38699222461?pr=1557#step:7:10):in `initialize'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/railtie.rb:184:in `new'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.[10](https://github.com/diowa/ruby3-rails6-bootstrap-heroku/actions/runs/13832314292/job/38699222461?pr=1557#step:7:11)/lib/rails/railtie.rb:184:in `instance'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/application.rb:100:in `instance'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7.10/lib/rails/railtie.rb:206:in `method_missing'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:[12](https://github.com/diowa/ruby3-rails6-bootstrap-heroku/actions/runs/13832314292/job/38699222461?pr=1557#step:7:13)8:in `block in preload'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:127:in `each'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:127:in `preload'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:176:in `serve'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:158:in `block in run'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:152:in `loop'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application.rb:152:in `run'
from /home/runner/work/ruby3-rails6-bootstrap-heroku/ruby3-rails6-bootstrap-heroku/vendor/bundle/ruby/3.1.0/gems/spring-4.3.0/lib/spring/application/boot.rb:25:in `<top (required)>'
from <internal:/opt/hostedtoolcache/Ruby/3.1.6/x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:[13](https://github.com/diowa/ruby3-rails6-bootstrap-heroku/actions/runs/13832314292/job/38699222461?pr=1557#step:7:14)6:in `require'
from <internal:/opt/hostedtoolcache/Ruby/3.1.6/x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
from -e:1:in `<main>'
Ref: https://github.com/diowa/ruby3-rails6-bootstrap-heroku/actions/runs/13832314292/job/38699222461?pr=1557
There are no issues with 4.2.1
I've tried to bisect but I didn't succeed
This is also reproducible by running rails c
$ rails c
~/.rvm/gems/ruby-3.1.6/gems/railties-6.1.7.10/lib/rails/railtie.rb:229:in `initialize': Rails::Application is abstract, you cannot instantiate it directly. (RuntimeError)
I am experiencing the same thing with Rails 6.1.7.10 and Ruby 3.1.5
Same thing here, any fixes?
I'm experiencing the same issue with Rails 6.1.7.9 and Ruby 3.4.2. Upon reviewing the changes at https://github.com/rails/spring/compare/v4.2.1...v4.3.0#diff-8079047024eafaf078a5ec33c6e989295d077b3306c92c168a4cc043c9f780b2R127-R131, I found that calling watcher.add Rails::Application.paths["config/initializers"].expanded raises this RuntimeError. However, I don't understand why this happens.
Downgrade to Spring 4.2.1 seems to be working on Rails 6.1.7.10 and Ruby 3.2.2.
I'm experiencing the same issue. Here are the versions I'm running.
- Rails 6.1.7.9
- Ruby 3.2.5
However, after some further exploration, I discovered that running the command in question subsequent times works as expected. Here is an example with rails console.
[repo]$ bundle exec spring rails console
/Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/railtie.rb:229:in `initialize': Rails::Application is abstract, you cannot instantiate it directly. (RuntimeError)
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/engine.rb:441:in `initialize'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/application.rb:129:in `initialize'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/railtie.rb:184:in `new'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/railtie.rb:184:in `instance'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/application.rb:100:in `instance'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/railties-6.1.7.9/lib/rails/railtie.rb:206:in `method_missing'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:128:in `block in preload'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:127:in `each'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:127:in `preload'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:176:in `serve'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:158:in `block in run'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:152:in `loop'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application.rb:152:in `run'
from /Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/spring-4.3.0/lib/spring/application/boot.rb:25:in `<top (required)>'
from <internal:/Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from <internal:/Users/harrylewis/.rbenv/versions/3.2.5/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from -e:1:in `<main>'
[repo]$ bundle exec spring rails console
Running via Spring preloader in process 18625
Loading development environment (Rails 6.1.7.9)
[1] [com][development](main)>
As others have said, downgrading to version 4.2.1 seems to correct this behaviour.
Rails 6.1.7.10. Ruby 3.2.8. Downgrading from spring 4.3.0 to 4.2.1 helped
While I could investigate the problem. Rails 6.1 isn't supported for a while. The test suite with that version of Rails fails in ways I can't even make it work. I recommend you to upgrade your applications. I'll change spring to raise an error why trying to load with any unsupported Rails versions.
It is possible that the fix for #737 will also fix this issue, but again, I don't want to promise we will support an old version of Rails