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 in a non-stdin/stdout PTY uses incorrect output for pagination #1992

Open
byteit101 opened this issue Mar 23, 2019 · 1 comment
Open
Labels

Comments

@byteit101
Copy link

Pry implicitly uses stdout for pagination, which is guaranteed incorrect when using pry in a non-stdout pty (ie. via PTY.open). It should use the configured output in that case.

Environment:

Setup (Terminal 1):

rvm use 2.6.2
gem install pry
git clone https://github.com/byteit101/rb-readline
cd rb-readline
git checkout pty-fixes
cd ..
hg clone https://bitbucket.org/byteit101/remotetty/
ruby -I rb-readline/lib remotetty/server.rb

Setup (Terminal 2):

ruby -I rb-readline/lib remotetty/client.rb
[1] pry(main)> ENV
[2] pry(main)>

Using MRI, I get the system pager less. Note that the pagination incorrectly appears in terminal 1 (the server).

(type q on terminal 1, then $pty_exit = true, enter, then ctrl-c on terminal 2 to exit)

Using JRuby, I get the pry simple pager. Note that the pagination correctly appears in terminal 2 (the client) in this case, and you can type enter/q for more, but note that https://github.com/pry/pry/blob/master/lib/pry/pager.rb#L116 directly assumes Readline is configured. I previously had a Readline2 with the pty, and Readline with stdio, which incorrectly requested input from Terminal 1 (the server). The current script works fine though, as I configured the global Readline class to use the pty.

@kyrylo kyrylo added the bug label May 2, 2019
@kyrylo kyrylo added this to the v0.13.0 milestone May 2, 2019
@kyrylo
Copy link
Member

kyrylo commented Aug 7, 2019

Thanks for the detailed description. This seems to be a tough nut to crack. We pipe Pry output to less and apparently it runs on the server. I'm not sure how to use less on the client but any ideas are welcome.

Pry on JRuby always uses SimplePager. It doesn't shell out to less, so it works fine for your scenario. Perhaps, the correct solution would be preferring SimplePager in the client-server scenario or not paging at all.

@kyrylo kyrylo removed this from the v0.13.0 milestone Mar 22, 2020
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

2 participants