byebug icon indicating copy to clipboard operation
byebug copied to clipboard

Backspace fails when using Open3

Open kevjames3 opened this issue 10 years ago • 18 comments

Shout out to Deivid: Long time, no talk :). Here is an interesting bug...

require 'open3'

include Open3

Open3.popen2e('echo Hello') do |input, stdOutErr, waitThread|
   byebug
end

Try entering a series of characters, and then pressing backspace. You are unable to press backspace on the command prompt and have it register on the interface (buffer flushing problem?). Pressing enter does register the inputs.

For example, I type in byebug at the breakpoint "stdErrf", then I try to erase the 'f' with backspace, the interface does not update. However, if I press enter, the value of stdErr is returned as the underlying workings registered the keyboard input, just not the interface.

Additional Info:

Ruby Version: ruby 2.0.0p247 (2013-06-27) [i386-mingw32] OS: Windows 7, Intel Processor Byebug Version: 2.7.0

kevjames3 avatar Apr 10 '14 00:04 kevjames3

Hi @kevjames3! You're back! And with you, your easy to reproduce bug reports!

Thanks man, I'll have a look soon.

deivid-rodriguez avatar Apr 10 '14 13:04 deivid-rodriguez

Hi @kevjames3! I couldn't reproduce this with your sample program but this is exactly the same issue I get when I use byebug to debug a server started with foreman start.

The problem here is that foreman handles output by the processes it starts "line by line", so until a full line is not in the corresponding process output buffer, foreman won't print it. This works well for foreman because it's usually used to start proceses that require no user input...

The bigger problem in my case is that terminal echoing is permanently turned off, and that I don't know why... Not sure how to solve this or #59.

deivid-rodriguez avatar Apr 17 '14 13:04 deivid-rodriguez

Well that is just messy. Did you try to reproduce this on Windows? If you have, then I have just the strangest desktop machine ever.

kevjames3 avatar Apr 29 '14 04:04 kevjames3

No I haven't... I will eventually!

deivid-rodriguez avatar Apr 29 '14 10:04 deivid-rodriguez

hey @ddollar, I don't think this is your bug, but do you happen to have any insight as to how to get around foreman seemingly not flushing the buffer on user input?

I guess this worked on previous rubies, with the debugger gem, so there must be some sort of workaround!

maxwell avatar Aug 08 '14 22:08 maxwell

Foreman does not even hook up stdin from the controlling terminal to any of the underlying processes (how would it know which one to send to?) so I'm not sure it will work here.

ddollar avatar Aug 11 '14 14:08 ddollar

@ddollar thank you so much for helping us understand here. I appreciate you taking the time, and foreman very much.

@deivid-rodriguez, do you happen to know how your terminal handling code differs from normal debugger from 2.0? I know it seemed to work, even with foreman, so perhaps there is a cool trick there we could take advantage of?

maxwell avatar Aug 11 '14 17:08 maxwell

No but feel free to investigate! I suggest you try the initial byebug release and if it works, write a test and use git bisect to find the offending commit.

deivid-rodriguez avatar Aug 11 '14 17:08 deivid-rodriguez

@kevjames3 I've been able to reproduce this on Windows. It seems like a very edge case because placing the byebug call anywhere else works.

@luislavena Do you think this could be related to readline. It seems that backspace has problems sometimes under Windows, right? Thanks!

deivid-rodriguez avatar Sep 30 '14 18:09 deivid-rodriguez

Fair enough, glad it is not just my desktop

kevjames3 avatar Oct 01 '14 15:10 kevjames3

Do we want to expand this issue to include it happening under Foreman, or shall I start a new one? Here's a video of how I see it.

davetapley avatar Oct 27 '14 21:10 davetapley

I really don't know where the boundary between this issue and #59 is. In any case, I'm aware of issues with Byebug not echoing to terminal.

deivid-rodriguez avatar Oct 27 '14 21:10 deivid-rodriguez

This could be fixed by bb98cd6.

sethk avatar Mar 23 '16 04:03 sethk

Could somebody experiencing this try latest master? :)

deivid-rodriguez avatar Mar 23 '16 08:03 deivid-rodriguez

@deivid-rodriguez wish I could, but I have moved onto another project that does not have an ENV enabled for this :(

kevjames3 avatar Mar 23 '16 18:03 kevjames3

Thanks anyways @kevjames3

deivid-rodriguez avatar Mar 23 '16 18:03 deivid-rodriguez

Sorry for the long wait. I still have problems on byebug (9.0.5), will try to use your master branch for a while to see if this happens again.

Startouf avatar Jul 28 '16 15:07 Startouf

@Startouf Note that you have to manually reapply https://github.com/deivid-rodriguez/byebug/commit/bb98cd60cfeceee8ce626a222346ef432e7d2a0e, which is not currently in master.

deivid-rodriguez avatar Jul 28 '16 16:07 deivid-rodriguez