Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pry on 1.7.5,1.7.6 - can't stop listing #1158

Closed
lowang opened this issue Oct 24, 2013 · 18 comments
Closed

Pry on 1.7.5,1.7.6 - can't stop listing #1158

lowang opened this issue Oct 24, 2013 · 18 comments
Labels
Milestone

Comments

@lowang
Copy link

lowang commented Oct 24, 2013

After an upgrade I've got a problem using pry, it starts ok but if a long list is inspected it says " --- Press enter to continue ( q to break ) --- " so just q + [enter] or ^c would do the trick. That was right till 1.7.5, now I've got:

<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>
q^Mq^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^C^M^M^M^M^M^M^M^M^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^M^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^M^M^M^M^M^M^M^M^M^M^M^M

To reproduce:

$ gem install pry
$ pry
[1] pry(main)> a = (0..1000).to_a

Note: ^Z works as expected. I've got this on OSX with jruby 1.7.5 & 1.7.6 via RVM & pry 0.9.12.2 on
Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) and Debian with jruby 1.7.5 via tarball on Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)

In jruby-1.7.4 everything works correctly both on osx & debian.

@dre-hh
Copy link

dre-hh commented Nov 7, 2013

confim

problem ocuurs on bash and zsh with Terminal and ITerm2, so i guess it must be jruby's Readline jar

jruby 1.7.6 (1.9.3p392) 2013-10-22 6004147 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 [darwin-x86_64]
OS X 10.9 Mavericks

@dre-hh
Copy link

dre-hh commented Nov 7, 2013

As long as it's broken you can disable long output paging (which is using less) by calling

Pry.config.pager = false

On a rails porject you can just put this code in an initializer

@lowang
Copy link
Author

lowang commented Nov 22, 2013

issue fixed by: pry/pry#992

@lowang lowang closed this as completed Nov 22, 2013
@headius headius reopened this Jan 17, 2014
@headius
Copy link
Member

headius commented Jan 17, 2014

I would prefer that issues are not closed just because a library or app works around them. There's a good chance this behavior is still broken in JRuby but we'd never know it because the issues get closed.

Was anyone ever able to narrow this down to a simple case in JRuby? There were a lot of IO-related changes in 1.7.5, but we don't want to regress on behavior.

@headius
Copy link
Member

headius commented Jan 17, 2014

Still appears to be an issue on jruby-1_7 as of today.

...
 53,
 54,
 55,
 56,

<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>
q^M

@headius
Copy link
Member

headius commented Jan 17, 2014

A backtrace of this shows that it's waiting for input, and that it's using the non-selectable ReadableChannel stuff. That may be the source of the regression, but I'll fix it and see.

@headius
Copy link
Member

headius commented Jan 17, 2014

It just occurred to me that there's something very odd going on for carriage returns to be showing up as ^M in the console. I think this is more than simply an IO issue; it's like the terminal has been reconfigured in some way.

@headius
Copy link
Member

headius commented Jan 17, 2014

A trivial example at the command line works fine; something's causing gets to go wacky.

$ jruby -e "loop { puts 'hello'; break if \$stdin.gets.chomp == 'q' }"
hello

hello

hello
q

$

@headius
Copy link
Member

headius commented Jan 17, 2014

Yeah, there's something really strange going on. I added logging to our lower-level IO stuff, and it shows that for some reason the enter key is sending \13 instead of \10 when running under pry.

At command line without pry:

system ~/projects/jruby-1.7 $ jruby -e "gets"
going into gets fast with delim = 10
asdf
byte at 0 is 97
byte at 1 is 115
byte at 2 is 100
byte at 3 is 102
byte at 4 is 10
read: 5
10

Under pry:

[1] pry(main)> gets
going into gets fast with delim = 10
^Mbyte at 0 is 13
^Mbyte at 0 is 13
^Mbyte at 0 is 13
^Mbyte at 0 is 13
^Mbyte at 0 is 13
^Mbyte at 0 is 13

byte at 0 is 10
read: 7
10
=> "\r\r\r\r\r\r\n"
[2] pry(main)> quit

The \10 that eventually gets sent is from me doing Ctrl-j.

There's a possibility this is a bug in how we handle mapping newline characters.

@headius
Copy link
Member

headius commented Jan 17, 2014

Ok, this looks like a regression in the readline library we use. I have narrowed down this behavior to the call to readline that occurs in Pry.readline (pry_instance.rb). Before that call, "enter" produces \10 characters. After the call, it produces \13 characters. This causes calls to gets to not see the default line terminator and exhibit the behavior reported in this bug. I'm not sure what's wrong with our readline library (jline) that would cause this.

@ghost
Copy link

ghost commented Jan 17, 2014

@headius ah, nice, thanks for getting to the bottom of it. hm okay, sounds tricky to solve?

@ghost
Copy link

ghost commented Jan 17, 2014

@headius how does rb-readline behave on jruby? could using that instead be a viable workaround?

@headius
Copy link
Member

headius commented Jan 17, 2014

rb-readline might be an option, but it uses a lot of low-level APIs...some of which we can only simulate atop the JVM.

@ghost
Copy link

ghost commented Jan 18, 2014

@headius thanks. with that in mind, I think we won't do that then.

@headius headius modified the milestones: JRuby 1.7.12, JRuby 1.7.11 Feb 21, 2014
@enebo enebo modified the milestones: JRuby 1.7.13, JRuby 1.7.12 Apr 15, 2014
@mrbrdo
Copy link
Contributor

mrbrdo commented Apr 16, 2014

Was this reported to jline? Any link to issue?
Is there any plan to resolve this? I only got it in pry and glad they worked around it, but would be nice to get to the bottom of it.

@enebo enebo modified the milestones: JRuby 1.7.14, JRuby 1.7.13 Jun 24, 2014
@enebo enebo modified the milestones: JRuby 1.7.14, JRuby 1.7.15 Aug 27, 2014
@mvdamme
Copy link

mvdamme commented Mar 3, 2015

I've just had the same issue with JRuby 1.7.19, so I guess the underlying issue hasn't been fixed yet.
ruby -v gives me the following output:
jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on OpenJDK 64-Bit Server VM 1.6.0_34-b34 +jit [linux-amd64]

@enebo enebo modified the milestones: Post-9000, JRuby 1.7.15 May 11, 2016
@enebo enebo added the stdlib label May 11, 2016
@enebo
Copy link
Member

enebo commented May 11, 2016

I am abandoning fixing this for 1.7.x but it is still present for 9.x. I am guessing it is still our library dependency not doing something we expect.

@headius
Copy link
Member

headius commented May 13, 2016

Let's go with the more recent bug for ^C not working in IRB anymore: #3721.

@headius headius closed this as completed May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants