deivid-rodriguez / byebug

Debugging in Ruby 2
BSD 2-Clause "Simplified" License
3.34k stars 328 forks source link

Backspace fails when using Open3 #63

Open kevjames3 opened 10 years ago

kevjames3 commented 10 years ago

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

deivid-rodriguez commented 10 years ago

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

Thanks man, I'll have a look soon.

deivid-rodriguez commented 10 years ago

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.

kevjames3 commented 10 years ago

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.

deivid-rodriguez commented 10 years ago

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

maxwell commented 10 years ago

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!

ddollar commented 10 years ago

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.

maxwell commented 10 years ago

@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?

deivid-rodriguez commented 10 years ago

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 commented 10 years ago

@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!

kevjames3 commented 10 years ago

Fair enough, glad it is not just my desktop

davetapley commented 9 years ago

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.

deivid-rodriguez commented 9 years ago

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.

sethk commented 8 years ago

This could be fixed by bb98cd6.

deivid-rodriguez commented 8 years ago

Could somebody experiencing this try latest master? :)

kevjames3 commented 8 years ago

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

deivid-rodriguez commented 8 years ago

Thanks anyways @kevjames3

Startouf commented 8 years ago

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.

deivid-rodriguez commented 8 years ago

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