rubocop / guard-rubocop

Guard plugin for RuboCop
MIT License
262 stars 55 forks source link

Corrupted terminal #30

Closed wojtha closed 7 years ago

wojtha commented 7 years ago

I've found that rubocop-guard is breaking my ZSH terminal (but it is happening in Bash as well), especially after some error was printed to STDOUT. I had to exit from guard and run stty sane to reset the terminal every time when this happen. This issue is bothering me for 2 months, but I was suspecting guard-rspec which I am using as well.

After some research I knew that is some ANSI escaping issue and that it is happening somewhere around Guard::UI or Guard::Compat::UI. Today I first tried to disable the guard-rubocop and the problem went away, then I discovered the PR #19 which promotes upgrade to "new" Guard::Compat API and I give it a try. When I applied patch in #19 the problem went away as well.

Before patch:

1 fsevent_watch 2016-10-09 01-38-00

guard-rubocop (1.2.0) guard (~> 2.0) rubocop (~> 0.20)

After patch:

1 fsevent_watch 2016-10-09 01-39-17

guard-rubocop (1.2.0-patched) guard (~> 2.0) guard-compat (~> 1.1) rubocop (~> 0.20)

System info

$ uname -a
Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
$ zsh --version
zsh --version
zsh 5.2 (x86_64-apple-darwin15.4.0)
wojtha commented 7 years ago

This was maybe just an accident. After a while the issue returned and happen again on regular basis again even with the PR #19.

I have tried various things since then, it seems that it is kind of readline/zeus/guard/macOS issue. See e.g. https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X

The simplest way is just add gem rb-readline to your development Gemfile. I've encountered several situations in past hours which I am sure would end up with corrupted terminal, but with rb-readline it works ok.