nonsequitur / inf-ruby

218 stars 69 forks source link

using inf-ruby with pry hangs emacs in windows #75

Closed jclosure closed 9 years ago

jclosure commented 9 years ago

Using inf-ruby on Windows causes an immediate freeze.

Emacs Version: 24.5 (both) Ruby Version: ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]. Windows version installed with the Ruby installer from Ruby website. Also has DevKit installed.

I have pry set default as follows:

(require 'inf-ruby) (add-to-list 'inf-ruby-implementations' ("pry". "Pry")) (setq inf-ruby-default-implementation "pry")

Steps to reproduce:

Open Emacs (runemacs in mingw terminal or runemacs.exe from NTEmacs)

M-x, inf-ruby (In Pry) puts "Hello" Emacs should freeze here

Using toggle-debug-on-quit and pressing C-g after freezing produces the following trace:

Debugger entered--Lisp error: (quit) accept-process-output(#) comint-send-input()

(comint-send-input nil nil)

ad-Advice-call-interactively(# comint-send-input nil nil) apply(ad-Advice-call-interactively # (comint-send-input nil nil)) call-interactively(comint-send-input nil nil) command-execute(comint-send-input)

Using pry from cmd.exe works fine:

cmd.exe: pry [1] pry(main)> puts "Hi" Hi => nil

dgutov commented 9 years ago

Does inf-ruby work fine when not using Pry?

Does pry work okay in M-x term?

jclosure commented 9 years ago

inf-ruby works fine with the defaults (irb). It's only with pry that it freezes.

To answer your question about M-x term, that doesn't work in Windows.
See these references on the topic: https://lists.gnu.org/archive/html/bug-gnu-emacs/2008-03/msg00098.html http://theanswerweb.com/data9/2015/07/24/bash-m-x-term-with-emacs-on-ms-windows-error-spawning-child-process-invalid-argument/

In win, we typically use: M-x shell or M-x eshell.

term and ansi-term are broken in Win.

use case context:

without (setq inf-ruby-default-implementation "pry") I do inf-ruby IRB prompt comes up. then I type puts "Hello" Hello is printed and returns to irb prompt

with (setq inf-ruby-default-implementation "pry") i do M-x inf-ruby Pry prompt comes up. then I type: puts "Hello" Hangs

Wonder why irb works but pry doesn't in inf-ruby. Interestingly, pry works fine from a plain cmd.exe session.

stardiviner commented 9 years ago

I have same issue, I'm using Arch Linux, and tried [M-x term] + pry. It can work. and inf-ruby use ruby implement works good. same issue, pry freezed. And when I toggle-debug-on-quit, it shows nothing.

jclosure commented 9 years ago

I reduced the repro setup to this:

  1. clean install of emacs-24.5-bin-i686-mingw32
  2. The only package installed is inf-ruby-2.3.2 (no other packages)
  3. set (setq inf-ruby-default-implementation "pry")

Debugger entered--Lisp error: (quit) accept-process-output(#process ruby) comint-send-input() call-interactively(comint-send-input nil nil) command-execute(comint-send-input)

dgutov commented 9 years ago

2.3.2? Where did you get that? Please try the code from this repo, directly or through MELPA.

jclosure commented 9 years ago

I got 2.3.2 from Marmalade.

However, I also just tested the version in Melpa (inf-ruby-20150813.1848). It also exhibits same hanging behavior.

On Wed, Sep 23, 2015 at 10:18 PM, Dmitry Gutov notifications@github.com wrote:

2.3.2? Where did you get that? Please try the code from this repo, directly or through MELPA.

— Reply to this email directly or view it on GitHub https://github.com/nonsequitur/inf-ruby/issues/75#issuecomment-142793854 .

jclosure commented 9 years ago

Ok, looks like a Readline issue with Pry + Emacs.

I got it working by putting this into my ~.pryrc:

class Emacsable def self.readline(prompt) print prompt (gets || '').chomp end end Pry.config.input = Emacsable

Now, when I run inf-ruby with pry, it no longer hangs and the repl behaves as expected.

Ref: https://github.com/pry/pry/issues/1026

dgutov commented 9 years ago

I figured it might be related to Readline... however, what does trigger the freeze exactly? Is there no prompts after => ...? Or the prompt is preceded with spaces? @stardiviner might be the best positioned to answer this: just try it in pry under M-x term.

@jclosure Have you tried installing rb-readline instead? Like previous versions of Pry suggested: https://github.com/pry/pry/commit/c80c2031aa6bf27e5824d7b5f0b9ebd795b3c506

stardiviner commented 9 years ago

@dgutov here is what I get when I run pry under M-x term. And another one is I run inf-ruby with pry implement (without @jclosure's config). And when I first time input puts "hello", then press [RET], no reponse, just move to next line, and I input puts "hello" again, still no output.

inf-ruby pry freeze 1

inf-ruby pry freeze 2

dgutov commented 9 years ago

@stardiviner I see, thank you. Alas, the M-x term history looks normal, so it doesn't tell me much.

mohkale commented 5 years ago

I've encountered the same error, and doing @jclosure solution fixed it. Could you consider adding this to the bottom of the README alongside the other bug fixes? took me two hours to figure out what the problem was (spent most of it thinking I just installed the dependencies wrong 😋😋😋). Anyways, thnx for resolving the issue.

dgutov commented 5 years ago

That sounds like working around an actual bug (and one I don't fully understand).

Shouldn't someone file a bug report at an appropriate place first?