spring: Spring hangs a lot

We’ve been having a lot of problems with spring hanging on our systems. I started outputting to a log and here’s what I see:

[2015-03-19 14:27:01 -0700] [21417] [application:test] initialized -> running
/home/fletch/.rvm/gems/ruby-2.1.5/gems/spring-1.3.3/lib/spring/application.rb:286:in `read': stream closed (IOError)
    from /home/fletch/.rvm/gems/ruby-2.1.5/gems/spring-1.3.3/lib/spring/application.rb:286:in `block (2 levels) in with_pty'
[2015-03-19 14:27:01 -0700] [12838] [application_manager:test] child 21417 shutdown
[2015-03-19 14:27:01 -0700] [21531] [application:test] preloading app
[2015-03-19 14:27:06 -0700] [21531] [application:test] initialized -> running
/home/fletch/.rvm/gems/ruby-2.1.5/gems/spring-1.3.3/lib/spring/application.rb:286:in `read': stream closed (IOError)
    from /home/fletch/.rvm/gems/ruby-2.1.5/gems/spring-1.3.3/lib/spring/application.rb:286:in `block (2 levels) in with_pty'

I haven’t got a strong idea of what is causing it just yet, though it seems to come up if we change git branches and the like, so maybe some sort of file changes are causing it to just lock up. We have to run spring stop and start over.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 13
  • Comments: 59 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Spring 2.0.2, Rails 5.1.4. Happens so much that I have an alias for spring stop

+1 Spring status says Spring is not running (because I stopped it), but ps shows Spring processes still going.

Seeing spring hang a lot with a new Rails 5.2.1 project on macOS 10.13.5 High Sierra

Only thing I can do is kill -9 the Ruby process, and then bin/spring stop, followed by bin/rails test

Seems to happen most often when files in the config directory are modified.

Maybe this will help someone: while in the beginning I thought that spring is the issue, in my specific case ruby process eating 100% CPU was solved by explicitly updating listen gem version used in spring-watcher-listen gem that we had in the project.

Wow, 7 years later, finally fixed! 🎉

Rails 5.1.5, Spring 2.0.2 hangs more often than not when running ‘rails c’.

I don’t know if this is the same bug, and while it is an odd scenario, it is 100% reproducible with Rails 5.1, Spring 2.0.2, and Mac OS/X High Sierra:

rails new project; cd project; bin/rails generate scaffold Product name; cd ..; rm -rf project; rails new project; cd project; bin/rails generate scaffold Product name

Generally, control-C isn’t enough to stop the process, it requires killing. Once killed, retrying the generate scaffold command once again hangs, unless a spring stop is done before then (yes, in the newly recreated project directory).

Hope this helps.

After a lot of tinkering I was able to figure out why it happens, at least in my case.

First, Spring hangs when checking out a branch that has changes in one of the monitored files: Gemfile or config files. In this case Spring reloads an application on background. If your application prints any warnings on initialise the process will wait to access STDOUT which never happens as Spring’s application process runs on background. In my case the solution was to disable warnings with $VERBOSE=nil on top of the config/application.rb because the app wasn’t trying to print anything but warnings. But of course it won’t do if you want to keep seeing warnings.

Kind of related, and kind of good news: Spring is not default anymore https://github.com/rails/rails/pull/42997

Jan 2021, it’s seems the issue still exists. When I start rails c, I see a ruby proccess that comsumes 100% cpu. The proccess is not killed even I exit rails c Screen Shot 2021-01-15 at 10 02 51

[2021-01-15 10:06:32 +0700] [24141] [server] started on /var/folders/nk/bft63hfj68j6c9xhgxz5cqdw0000gn/T/spring-501/0faafd75253802bff51729462f6c05a6
[2021-01-15 10:06:43 +0700] [24141] [server] accepted client
[2021-01-15 10:06:43 +0700] [24141] [server] running command rails_console
[2021-01-15 10:06:43 +0700] [24141] [application_manager:development] child not running; starting
[2021-01-15 10:06:43 +0700] [24402] [application:development] initialized -> running
[2021-01-15 10:06:43 +0700] [24402] [application:development] got client
[2021-01-15 10:06:43 +0700] [24402] [application:development] preloading app
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: ["/Users/owen/GoldenOwl/Client_Ready/clientready/.env"]
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: [["/Users/owen/GoldenOwl/Client_Ready/clientready/config/spring.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/config/boot.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/config/initializers/config.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/config/application.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/config/environments/development.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/app/mailers/application_mailer.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/app/mailers/custom_devise_mailer.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/app/models/application_record.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/app/models/concerns/custom_validators.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/app/models/user.rb", "/Users/owen/GoldenOwl/Client_Ready/clientready/config/environment.rb"]]
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: [#<Pathname:/Users/owen/GoldenOwl/Client_Ready/clientready/Gemfile>, "/Users/owen/GoldenOwl/Client_Ready/clientready/Gemfile.lock"]
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: [#<Rails::Paths::Path:0x00007f8e25f819d8 @paths=["config/initializers"], @current="config/initializers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 @path=#<Pathname:/Users/owen/GoldenOwl/Client_Ready/clientready>, @root={"app"=>#<Rails::Paths::Path:0x00007f8e25f82018 @paths=["app"], @current="app", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="{*,*/concerns}", @exclude=["assets", "javascript"], @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/assets"=>#<Rails::Paths::Path:0x00007f8e25f81fa0 @paths=["app/assets"], @current="app/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/controllers"=>#<Rails::Paths::Path:0x00007f8e25f81f28 @paths=["app/controllers"], @current="app/controllers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/channels"=>#<Rails::Paths::Path:0x00007f8e25f81eb0 @paths=["app/channels"], @current="app/channels", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*_channel.rb", @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/helpers"=>#<Rails::Paths::Path:0x00007f8e25f81e38 @paths=["app/helpers"], @current="app/helpers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/models"=>#<Rails::Paths::Path:0x00007f8e25f81dc0 @paths=["app/models"], @current="app/models", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/mailers"=>#<Rails::Paths::Path:0x00007f8e25f81d48 @paths=["app/mailers"], @current="app/mailers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/views"=>#<Rails::Paths::Path:0x00007f8e25f81cd0 @paths=["app/views"], @current="app/views", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib"=>#<Rails::Paths::Path:0x00007f8e25f81c58 @paths=["lib"], @current="lib", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "lib/assets"=>#<Rails::Paths::Path:0x00007f8e25f81be0 @paths=["lib/assets"], @current="lib/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/tasks"=>#<Rails::Paths::Path:0x00007f8e25f81b68 @paths=["lib/tasks"], @current="lib/tasks", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*.rake", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config"=>#<Rails::Paths::Path:0x00007f8e25f81af0 @paths=["config"], @current="config", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environments"=>#<Rails::Paths::Path:0x00007f8e25f81a50 @paths=["config/environments"], @current="config/environments", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="development.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/initializers"=>#<Rails::Paths::Path:0x00007f8e25f819d8 ...>, "config/locales"=>#<Rails::Paths::Path:0x00007f8e25f81960 @paths=["config/locales"], @current="config/locales", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*.{rb,yml}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/routes.rb"=>#<Rails::Paths::Path:0x00007f8e25f818e8 @paths=["config/routes.rb"], @current="config/routes.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db"=>#<Rails::Paths::Path:0x00007f8e25f81870 @paths=["db"], @current="db", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/migrate"=>#<Rails::Paths::Path:0x00007f8e25f817f8 @paths=["db/migrate"], @current="db/migrate", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/seeds.rb"=>#<Rails::Paths::Path:0x00007f8e25f81780 @paths=["db/seeds.rb"], @current="db/seeds.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "vendor"=>#<Rails::Paths::Path:0x00007f8e25f81708 @paths=["vendor"], @current="vendor", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "vendor/assets"=>#<Rails::Paths::Path:0x00007f8e25f81690 @paths=["vendor/assets"], @current="vendor/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/database"=>#<Rails::Paths::Path:0x00007f8e25f81618 @paths=["config/database.yml"], @current="config/database", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/secrets"=>#<Rails::Paths::Path:0x00007f8e25f815a0 @paths=["config"], @current="config/secrets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="secrets.yml{,.enc}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environment"=>#<Rails::Paths::Path:0x00007f8e25f81528 @paths=["config/environment.rb"], @current="config/environment", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/templates"=>#<Rails::Paths::Path:0x00007f8e25f814b0 @paths=["lib/templates"], @current="lib/templates", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "log"=>#<Rails::Paths::Path:0x00007f8e25f81410 @paths=["log/development.log"], @current="log", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public"=>#<Rails::Paths::Path:0x00007f8e25f81398 @paths=["public"], @current="public", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/javascripts"=>#<Rails::Paths::Path:0x00007f8e25f81320 @paths=["public/javascripts"], @current="public/javascripts", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/stylesheets"=>#<Rails::Paths::Path:0x00007f8e25f812a8 @paths=["public/stylesheets"], @current="public/stylesheets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "tmp"=>#<Rails::Paths::Path:0x00007f8e25f81230 @paths=["tmp"], @current="tmp", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/cable"=>#<Rails::Paths::Path:0x00007f8e243d8dd0 @paths=["config/cable.yml"], @current="config/cable", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/decorators"=>#<Rails::Paths::Path:0x00007f8e2161ec00 @paths=["app/decorators"], @current="app/decorators", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>}>, @glob="**/*.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>]
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: [#<Rails::Paths::Path:0x00007f8e25f81618 @paths=["config/database.yml"], @current="config/database", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 @path=#<Pathname:/Users/owen/GoldenOwl/Client_Ready/clientready>, @root={"app"=>#<Rails::Paths::Path:0x00007f8e25f82018 @paths=["app"], @current="app", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="{*,*/concerns}", @exclude=["assets", "javascript"], @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/assets"=>#<Rails::Paths::Path:0x00007f8e25f81fa0 @paths=["app/assets"], @current="app/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/controllers"=>#<Rails::Paths::Path:0x00007f8e25f81f28 @paths=["app/controllers"], @current="app/controllers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/channels"=>#<Rails::Paths::Path:0x00007f8e25f81eb0 @paths=["app/channels"], @current="app/channels", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*_channel.rb", @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/helpers"=>#<Rails::Paths::Path:0x00007f8e25f81e38 @paths=["app/helpers"], @current="app/helpers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/models"=>#<Rails::Paths::Path:0x00007f8e25f81dc0 @paths=["app/models"], @current="app/models", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/mailers"=>#<Rails::Paths::Path:0x00007f8e25f81d48 @paths=["app/mailers"], @current="app/mailers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/views"=>#<Rails::Paths::Path:0x00007f8e25f81cd0 @paths=["app/views"], @current="app/views", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib"=>#<Rails::Paths::Path:0x00007f8e25f81c58 @paths=["lib"], @current="lib", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "lib/assets"=>#<Rails::Paths::Path:0x00007f8e25f81be0 @paths=["lib/assets"], @current="lib/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/tasks"=>#<Rails::Paths::Path:0x00007f8e25f81b68 @paths=["lib/tasks"], @current="lib/tasks", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*.rake", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config"=>#<Rails::Paths::Path:0x00007f8e25f81af0 @paths=["config"], @current="config", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environments"=>#<Rails::Paths::Path:0x00007f8e25f81a50 @paths=["config/environments"], @current="config/environments", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="development.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/initializers"=>#<Rails::Paths::Path:0x00007f8e25f819d8 @paths=["config/initializers"], @current="config/initializers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/locales"=>#<Rails::Paths::Path:0x00007f8e25f81960 @paths=["config/locales"], @current="config/locales", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*.{rb,yml}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/routes.rb"=>#<Rails::Paths::Path:0x00007f8e25f818e8 @paths=["config/routes.rb"], @current="config/routes.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db"=>#<Rails::Paths::Path:0x00007f8e25f81870 @paths=["db"], @current="db", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/migrate"=>#<Rails::Paths::Path:0x00007f8e25f817f8 @paths=["db/migrate"], @current="db/migrate", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/seeds.rb"=>#<Rails::Paths::Path:0x00007f8e25f81780 @paths=["db/seeds.rb"], @current="db/seeds.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "vendor"=>#<Rails::Paths::Path:0x00007f8e25f81708 @paths=["vendor"], @current="vendor", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "vendor/assets"=>#<Rails::Paths::Path:0x00007f8e25f81690 @paths=["vendor/assets"], @current="vendor/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/database"=>#<Rails::Paths::Path:0x00007f8e25f81618 ...>, "config/secrets"=>#<Rails::Paths::Path:0x00007f8e25f815a0 @paths=["config"], @current="config/secrets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="secrets.yml{,.enc}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environment"=>#<Rails::Paths::Path:0x00007f8e25f81528 @paths=["config/environment.rb"], @current="config/environment", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/templates"=>#<Rails::Paths::Path:0x00007f8e25f814b0 @paths=["lib/templates"], @current="lib/templates", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "log"=>#<Rails::Paths::Path:0x00007f8e25f81410 @paths=["log/development.log"], @current="log", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public"=>#<Rails::Paths::Path:0x00007f8e25f81398 @paths=["public"], @current="public", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/javascripts"=>#<Rails::Paths::Path:0x00007f8e25f81320 @paths=["public/javascripts"], @current="public/javascripts", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/stylesheets"=>#<Rails::Paths::Path:0x00007f8e25f812a8 @paths=["public/stylesheets"], @current="public/stylesheets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "tmp"=>#<Rails::Paths::Path:0x00007f8e25f81230 @paths=["tmp"], @current="tmp", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/cable"=>#<Rails::Paths::Path:0x00007f8e243d8dd0 @paths=["config/cable.yml"], @current="config/cable", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/decorators"=>#<Rails::Paths::Path:0x00007f8e2161ec00 @paths=["app/decorators"], @current="app/decorators", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>}>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>]
[2021-01-15 10:06:44 +0700] [24402] [watcher:development] watcher: add: [#<Rails::Paths::Path:0x00007f8e25f815a0 @paths=["config"], @current="config/secrets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 @path=#<Pathname:/Users/owen/GoldenOwl/Client_Ready/clientready>, @root={"app"=>#<Rails::Paths::Path:0x00007f8e25f82018 @paths=["app"], @current="app", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="{*,*/concerns}", @exclude=["assets", "javascript"], @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/assets"=>#<Rails::Paths::Path:0x00007f8e25f81fa0 @paths=["app/assets"], @current="app/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/controllers"=>#<Rails::Paths::Path:0x00007f8e25f81f28 @paths=["app/controllers"], @current="app/controllers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/channels"=>#<Rails::Paths::Path:0x00007f8e25f81eb0 @paths=["app/channels"], @current="app/channels", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*_channel.rb", @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/helpers"=>#<Rails::Paths::Path:0x00007f8e25f81e38 @paths=["app/helpers"], @current="app/helpers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/models"=>#<Rails::Paths::Path:0x00007f8e25f81dc0 @paths=["app/models"], @current="app/models", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/mailers"=>#<Rails::Paths::Path:0x00007f8e25f81d48 @paths=["app/mailers"], @current="app/mailers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/views"=>#<Rails::Paths::Path:0x00007f8e25f81cd0 @paths=["app/views"], @current="app/views", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib"=>#<Rails::Paths::Path:0x00007f8e25f81c58 @paths=["lib"], @current="lib", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "lib/assets"=>#<Rails::Paths::Path:0x00007f8e25f81be0 @paths=["lib/assets"], @current="lib/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/tasks"=>#<Rails::Paths::Path:0x00007f8e25f81b68 @paths=["lib/tasks"], @current="lib/tasks", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*.rake", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config"=>#<Rails::Paths::Path:0x00007f8e25f81af0 @paths=["config"], @current="config", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environments"=>#<Rails::Paths::Path:0x00007f8e25f81a50 @paths=["config/environments"], @current="config/environments", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="development.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/initializers"=>#<Rails::Paths::Path:0x00007f8e25f819d8 @paths=["config/initializers"], @current="config/initializers", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="**/*.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/locales"=>#<Rails::Paths::Path:0x00007f8e25f81960 @paths=["config/locales"], @current="config/locales", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*.{rb,yml}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/routes.rb"=>#<Rails::Paths::Path:0x00007f8e25f818e8 @paths=["config/routes.rb"], @current="config/routes.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db"=>#<Rails::Paths::Path:0x00007f8e25f81870 @paths=["db"], @current="db", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/migrate"=>#<Rails::Paths::Path:0x00007f8e25f817f8 @paths=["db/migrate"], @current="db/migrate", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/seeds.rb"=>#<Rails::Paths::Path:0x00007f8e25f81780 @paths=["db/seeds.rb"], @current="db/seeds.rb", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "vendor"=>#<Rails::Paths::Path:0x00007f8e25f81708 @paths=["vendor"], @current="vendor", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "vendor/assets"=>#<Rails::Paths::Path:0x00007f8e25f81690 @paths=["vendor/assets"], @current="vendor/assets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/database"=>#<Rails::Paths::Path:0x00007f8e25f81618 @paths=["config/database.yml"], @current="config/database", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/secrets"=>#<Rails::Paths::Path:0x00007f8e25f815a0 ...>, "config/environment"=>#<Rails::Paths::Path:0x00007f8e25f81528 @paths=["config/environment.rb"], @current="config/environment", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/templates"=>#<Rails::Paths::Path:0x00007f8e25f814b0 @paths=["lib/templates"], @current="lib/templates", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "log"=>#<Rails::Paths::Path:0x00007f8e25f81410 @paths=["log/development.log"], @current="log", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public"=>#<Rails::Paths::Path:0x00007f8e25f81398 @paths=["public"], @current="public", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/javascripts"=>#<Rails::Paths::Path:0x00007f8e25f81320 @paths=["public/javascripts"], @current="public/javascripts", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/stylesheets"=>#<Rails::Paths::Path:0x00007f8e25f812a8 @paths=["public/stylesheets"], @current="public/stylesheets", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "tmp"=>#<Rails::Paths::Path:0x00007f8e25f81230 @paths=["tmp"], @current="tmp", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/cable"=>#<Rails::Paths::Path:0x00007f8e243d8dd0 @paths=["config/cable.yml"], @current="config/cable", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/decorators"=>#<Rails::Paths::Path:0x00007f8e2161ec00 @paths=["app/decorators"], @current="app/decorators", @root=#<Rails::Paths::Root:0x00007f8e25f820e0 ...>, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>}>, @glob="secrets.yml{,.enc}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>]
[2021-01-15 10:06:44 +0700] [24402] [application:development] forked 24415
[2021-01-15 10:06:44 +0700] [24141] [application_manager:development] got worker pid 24415








[2021-01-15 10:07:08 +0700] [24402] [application:development] 24415 exited with 0
[2021-01-15 10:07:19 +0700] [24141] [server] shutting down
[2021-01-15 10:07:19 +0700] [24141] [application_manager:development] stopping
[2021-01-15 10:07:19 +0700] [24402] [application:development] running -> terminating
[2021-01-15 10:07:19 +0700] [24402] [application:development] terminating -> exiting
[2021-01-15 10:07:19 +0700] [24141] [application_manager:development] child 24402 shutdown

Okay, I’ve played with it a little and here’s what I found. Spring freezes during eager preload. That happens when PTY that we provided gets written more than X bytes without being read from the other end. Normally, we would read that using the other thread that we spawn. However, when ruby issues warnings like “previous definition of XXX was here”, it uses blocking writes. Blocking write starts writing and PTY gets clogged. We can’t do anything until we read something. But our reader is in the parallel thread. Which we never get to because we’re currently trying to write something to stderr.

I don’t know enough about why pty was introduced in the first place, however, as a workaround, I’m going to redirect STDERR to /dev/null in situations when we can’t see it (e.g. preloading in the background).

Hope that made any sense.

I’m still seeing this problem with the new spring release 2.1.1.

rails test hangs but

bin/rails test works fine for me 👍

  1. Still a problem. I have to stop it in order to be able to work with the Rails console.

hangs a lot … on ruby 2.5, rails 5.1.3 tried both spring 1.7.2 and 2.0.2

We still see a lot of slowdowns on the initial boot after upgrading to Rails 5 and spring 2.

rails (5.0.1) spring (2.0.1) spring-commands-rspec (1.0.4) spring-commands-rubocop (0.2.0) spring-watcher-listen (2.0.1)

DISABLE_SPRING=1 rails console takes about 8 seconds. rails console takes 75 seconds (1:15m). Subsequent calls are fast, since spring is now running.

Is there a way to have spring verbosely output what it’s doing and find where it’s hanging?

I also noticed that a new Rails 5.0 applications hangs and freezes and could not solve the problem for weeks until I commented out the spring gem. It only appeared in development environment where the spring gem was included. The normal logs say nothing, the application just hangs, which is extremely nasty and annoying.

I am having the same issue (I do have dnsruby gem in my project), either with @markiz solution or 1.7.2 version. Anyone else seeing the same?

Experienced similar hanging with every “rails”-command on Rails 6.1.5 and after trying all kind of sorcery and witchcraft I ended up regenerating binstubs with “rake app:update:bin”. This solved all “rails”-command issues for me.

Maybe this will help someone: while in the beginning I thought that spring is the issue, in my specific case ruby process eating 100% CPU was solved by explicitly updating listen gem version used in spring-watcher-listen gem that we had in the project.

Worked. Thank you 👍

Not to pile on, but this is definitely reproducible with a minimal rails application.

rails new --skip-webpack-install --api test_spring && cd test_spring   
echo "ENV.fetch('FOOBAR')" > config/initializers/foo.rb  
bin/rails c # This hangs, prevents CTRL-C, CTRL-\, etc. from working
DISABLE_SPRING=1 bin/rails c # this works fine

Tested this with Ruby 3.0.0 but have seen the same behavior for a long time with other ruby versions.

I tried with the #693 fork changes and it didn’t seem to fix this particular issue.

I did find something just now that might be interesting/relevant: this error only happens when I’m inside tmux. I wonder how many other people in this thread are using tmux?

I typically have no other problems with tmux and tmux itself isn’t hung up; even when it hangs I can create a new buffer & then issue pkill -9 ruby to kill the hanging process

Edit: I’ve also tried updating the listen gem and have seen mixed results

Edit 2: I’ve tested a modified version of my commands above inside of tmux; newest stable ruby + rails + manually activate & install spring + manually start spring. The patch noted at the bottom of this thread in #623 appears to fix it. Spring no longer hangs in tmux; it raises the correct/expected “key not found” error message

I’m having the exact same problem with Rails 5.0.2 and Spring 2.0.2 on my mac. When I run rails console the process hangs, I can’t stop it with CMD+C, and I have to kill the process with the kill command. Sometimes the kill command is not enough and I have to restart my mac or comment out the spring gem.

I did a bunch of debugging today on an app where spring was nearly unusable and it turns out that removing the dnsruby gem from the Gemfile solved the problem. Not sure what the cause of the issue is (could be related to the use of timeout) but hope this helps someone.

Ctrl+C won’t get me out of it, either. I have to kill the process from elsewhere.

I had spring hang regularly, sometimes every five minutes. I’ve manually applied the patch in https://github.com/markiz/spring/commit/5f3ab734fc45d541aaaccb05b59cd95aa49fe8ef and haven’t seen any hangs since. As per https://github.com/rails/spring/issues/396#issuecomment-248906237 I’m going to submit that patch as a PR. Conveniently, it’s also on a branch.

Try Zeus instead - https://github.com/burke/zeus We’ve been using it for a more than a year in our workplace. It’s not perfect, but more stable than Spring at least.

This is happening all the time for a private project that I work on. Here’s how I can recreate it at will:

Terminal 1 spring stop; spring server;

Terminal 2 rails runner 'puts 1 + 1' touch config/application.rb

You will see a socket closed exception logged to terminal 1 and the spring server will hang. Any subsequent spring commands will hang indefinitely.

This isn’t the case for all projects though 😞

You can try my fix: https://github.com/rails/spring/pull/484. It should help with hanging rails console 😃