guard: Ctrl-C crashes guard

Whenever I try to cancel running tests (with guard-rspec plugin) the guard shell crashes and the tests continue. I can reproduce simply by opening guard and pressing ctrl-c. Full debug session output and diagnostic info below. It might be related to ruby version as it works fine on 2.3.0 but not 2.3.1.

$ bundle exec guard --debug
13:09:37 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
13:09:37 - DEBUG - Notiffany: growl not available (Unsupported platform "linux-gnu").
13:09:37 - DEBUG - Notiffany: terminal_notifier not available (Unsupported platform "linux-gnu").
13:09:37 - DEBUG - Notiffany: libnotify not available (Please add "gem 'libnotify'" to your Gemfile and run your app with "bundle exec".).
13:09:37 - DEBUG - Command execution: which notify-send
13:09:37 - DEBUG - Notiffany: notifysend not available (libnotify-bin package is not installed).
13:09:37 - DEBUG - Notiffany: notifu not available (Unsupported platform "linux-gnu").
13:09:37 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
13:09:37 - DEBUG - Notiffany: emacs not available (Emacs client failed).
13:09:37 - DEBUG - Command execution: tmux -V
13:09:37 - DEBUG - Notiffany: file not available (No :path option given).
13:09:37 - DEBUG - Command execution: tmux -V
13:09:37 - DEBUG - Notiffany is using Tmux to send notifications.
13:09:37 - DEBUG - Command execution: tmux list-clients -F '#{client_tty}'
13:09:37 - DEBUG - Command execution: tmux show -t /dev/pts/0
13:09:37 - DEBUG - Notiffany is using TerminalTitle to send notifications.
13:09:37 - DEBUG - Command execution: hash stty
13:09:37 - DEBUG - Guard starts all plugins
13:09:37 - DEBUG - Hook :start_begin executed for Guard::RSpec
13:09:37 - INFO - Guard::RSpec is running
13:09:37 - DEBUG - Hook :start_end executed for Guard::RSpec
13:09:38 - INFO - Guard is now watching at '/mnt/data1/home/andrew/projects/039-disciple/disciple-api'
13:09:38 - DEBUG - Start interactor
[1] guard(main)>  [ pressed ctrl-c here ]
[1] guard(main)> ⏎                                                                                                                                                                                                                                                                                                            $  [typed a few random characters]
$ aError: Input/output error - read
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:198:in `readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:198:in `block in input_readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:115:in `interruptible_region'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:197:in `input_readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:183:in `block in read_line'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:129:in `handle_read_errors'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:170:in `read_line'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:98:in `read'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:68:in `block in repl'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `loop'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `repl'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `block in start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:61:in `__with_ownership'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:79:in `with_ownership'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:15:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/pry_class.rb:169:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-byebug-3.4.0/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/guard-2.14.0/lib/guard/jobs/pry_wrapper.rb:102:in `block (2 levels) in _switch_to_pry'
[... this section below repeats several times ...]
[1] guard(main)> Error: Input/output error - read
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:198:in `readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:198:in `block in input_readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:115:in `interruptible_region'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:197:in `input_readline'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:183:in `block in read_line'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:129:in `handle_read_errors'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:170:in `read_line'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:98:in `read'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:68:in `block in repl'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `loop'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `repl'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `block in start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:61:in `__with_ownership'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:79:in `with_ownership'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:15:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.3/lib/pry/pry_class.rb:169:in `start'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-byebug-3.4.0/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug'
/home/andrew/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/guard-2.14.0/lib/guard/jobs/pry_wrapper.rb:102:in `block (2 levels) in _switch_to_pry'
[... end of repeating section ...]
[1] guard(main)> Error: Input/output error - read
FATAL: Pry failed to get user input using `Readline`.
To fix this you may be able to pass input and output file descriptors to pry directly. e.g.
  Pry.config.input = STDIN
  Pry.config.output = STDOUT
  binding.pry

13:11:22 - DEBUG - Interactor was stopped or killed
13:11:22 - DEBUG - Guard stops all plugins
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 status-left-bg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 status-right-bg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 status-left-fg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 status-right-fg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 message-bg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 message-fg
13:11:22 - DEBUG - Command execution: tmux set -q -u -t /dev/pts/0 display-time
$ uname -a
Linux triton.avito.uk 4.5.0-x86_64-linode65 #2 SMP Mon Mar 14 18:01:58 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

As far as I can tell my Ruby 2.3.1 is compiled with Readline support:

$ ruby -rreadline -e 'puts Readline::VERSION'
6.3

Unfortunately I’m not sure what the next steps are to debug this.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 1
  • Comments: 21 (9 by maintainers)

Most upvoted comments

I’m not sure if related, but when I CTRL-C during RSpec I fall back into pry, but guard will never run anything again. I haven’t tried debugging it very much. Behavior is the same with and without bundle exec. I tried running with the branches you specified above and it did make a difference where my guard would exit after stopping RSpec.

Any idea? Is it related to this? I’m happy to dig into internals if you don’t have an immediate idea about this. We have a lot of slow specs and being able to stop a spec mid-way would save a lot of time. 😃

I’m also having this issue on MacOs Sierra.

When I cancel a test, next changes on file doesn’t run tests. It stops watching.

I am also experiencing this (effectively same stack trace), but using Ruby v2.3.0, Guard v2.13.0.

If I run Guard via bundle exec guard and then press Ctrl-C at the prompt, I see the issue. However, if I run guard not through bundle, Pressing Ctrl-C does not cause the issue.

Full Ruby and Readline versions:

$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15.5.0]
$ ruby -rreadline -e 'puts Readline::VERSION'
6.3

After the Pry prompt errors out, I get terminal corruption similar to what is described here: https://github.com/pry/pry/issues/1275 https://github.com/pry/pry/issues/1183 https://github.com/guard/guard/issues/719

If I manually install the rb-readline gem, this fixes the corruption issue that occurs afterwards, but Ctrl-C yields the same stacktrace. With this gem installed, guard reports my Readline version as follows:

[1] guard(main)> Readline::VERSION
=> "5.2"

I’m having the same issue. Any updates on this?

Same problem here. Using macOS Catalina.

It looks like a combination of a few things.

I’ll likely create a “quickfix” branch and later work out how to integrate it.

Thanks @Odaeus for checking this out.

First, I screwed up the non-pry interactor. (I just pushed a commit, to fix this).

Second, you ran into this rb-inotify bug: https://github.com/nex3/rb-inotify/pull/59

For which I created a fix (not merged or released yet).

Until then, you use this in your Gemfile:

gem 'rb-inotify', github: 'e2/rb-inotify', branch: 'e2-fix_ioerror_when_closed'

That will solve problem 2.

For problem 3 - that’s probably a work in progress, but make sure you have in your Guardfile:

UI.options.merge!(flush_seconds: 0, level: :debug, device: 'guard.log')
notification :off

And you can use tail -f guard.log on the output in another window.

I’m worried the whole Pry session handling would have to be redesigned to fix this properly. That’ll probably take a whole Saturday to work out 😦

If I have anymore patches I’ll let everyone here know ASAP.