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

Updated jruby-readline alters terminal settings, breaking interactive prompts #5387

Closed
headius opened this Issue Oct 30, 2018 · 13 comments

Comments

Projects
None yet
3 participants
@headius
Copy link
Member

commented Oct 30, 2018

Something that jirb boots on a Linux or OS X system appears to be altering the tty settings.

[] ~/projects/jruby $ stty
speed 9600 baud;
lflags: echoe echoke echoctl pendin
iflags: iutf8
oflags: -oxtabs
cflags: cs8 -parenb

[] ~/projects/jruby $ jirb
irb(main):001:0> exit

[] ~/projects/jruby $ stty
speed 9600 baud;
lflags: -icanon echoe echoke echoctl
iflags: -icrnl -ixon iutf8
oflags: -oxtabs
cflags: cs8 -parenb
dsusp   lnext   
<undef> <undef>

Note that after running jirb, several tty settings change including -icrnl, which breaks most interactive prompts.

@headius headius added this to the JRuby 9.2.1.0 milestone Oct 30, 2018

@headius

This comment has been minimized.

Copy link
Member Author

commented Oct 30, 2018

Booting jirb with --noreadline appears to be ok. It looks like recent updates to jruby-readline may be to blame. @kares perhaps you can try to sort out which of your changes over the summer caused this?

@headius

This comment has been minimized.

Copy link
Member Author

commented Oct 30, 2018

I have reverted the update to jruby-readline and we can use this issue to track the process of fixing it, hopefully for 9.2.2.

@headius headius changed the title jirb alters terminal settings, breaking interactive prompts Updated jruby-readline alters terminal settings, breaking interactive prompts Oct 30, 2018

@kares

This comment has been minimized.

Copy link
Member

commented Oct 31, 2018

oh well, the jruby-readline update mostly updated the underlying readline library.
which seems to have been stucked with an old version, seemed to bring in some bug fixes and actually fixed some issues for me locally (linux). we shall look into whether a more recent update fixes the tty changes.

@kares

This comment has been minimized.

Copy link
Member

commented Oct 31, 2018

turns out jline 2.x isn't supported anymore - jruby-readline 1.3.0 was using latest version (2.14.6)

@kares

This comment has been minimized.

Copy link
Member

commented Oct 31, 2018

are you sure previous version doesn't alter settings such as -icrnl since the code looks the same.
... has been in since jline 2.8 (jruby-readline 1.2 uses 2.11 jruby/jruby-readline@177d726)

@enebo

This comment has been minimized.

Copy link
Member

commented Oct 31, 2018

@kares I just tried with master and I do not see stty being changed after using irb. .set() appears to call stty but perhaps they have some finalization or later stty which unsets that? Or maybe they added some explicit finalization we are not doing?

@kares

This comment has been minimized.

Copy link
Member

commented Oct 31, 2018

Or maybe they added some explicit finalization we are not doing?

thanks - did not try myself. that might do it - will try their terminal tear-down logic.

@headius

This comment has been minimized.

Copy link
Member Author

commented Oct 31, 2018

Yeah I suspect there's some teardown (or really, fix up) logic that either they or we are no longer running, like we're supposed to explicitly call something we're not.

kares added a commit to jruby/jruby-readline that referenced this issue Nov 7, 2018

[fix] attempt to restore terminal on exit
on JRuby runtime tear-down

we never did this but updated jline sets **-icrnl**
and that causes issues: jruby/jruby#5387

previous jline wasn't setting icrnl but still unresolved on restoring
see jruby/jruby#3181
@kares

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

OK, so I must have had something messy on my system, adding a runtime finalizer seems to work :

kares@clevo:~/workspace/oss/jruby$ bin/jruby -S gem install ../jruby-readline/pkg/jruby-readline-1.3.6.gem
Successfully installed jruby-readline-1.3.6-java
1 gem installed

kares@clevo:~/workspace/oss/jruby$ stty
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8

kares@clevo:~/workspace/oss/jruby$ bin/jruby -I./lib/ruby/gems/shared/gems/jruby-readline-1.3.6-java/lib/ -S irb
[DEBUG] Creating terminal; type=auto
[DEBUG] Config: speed 38400 baud; rows 60; columns 205; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc

[DEBUG] Created Terminal: jline.UnixTerminal@25af5db5
[DEBUG] Registering shutdown-hook: Thread[JLine Shutdown Hook,5,main]
[DEBUG] Adding shutdown-hook task: jline.TerminalSupport$1@7b69c6ba
[DEBUG] Ansi supported: true
[DEBUG] Echo enabled: false
[DEBUG] NonBlockingInputStream start
[DEBUG] Loaded user configuration: file:/etc/inputrc
[DEBUG] Echo enabled: false
irb(main):001:0>
[DEBUG] Echo enabled: true
[DEBUG] Echo enabled: false
irb(main):002:0> exit
[DEBUG] Echo enabled: true
[DEBUG] NonBlockingInputStream shutdown
[DEBUG] Removing shutdown-hook: Thread[JLine Shutdown Hook,5,main]

kares@clevo:~/workspace/oss/jruby$ stty
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8

stty getting properly restored as we exit, is this sufficient to have?

... prepared to release this as jruby-readline 1.3.6
the related diff would be pretty much these commits: jruby/jruby-readline@9607016...f6dfef2

@enebo enebo modified the milestones: JRuby 9.2.2.0, JRuby 9.2.3.0 Nov 7, 2018

@enebo

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

@kares we have a few holdups for 9.2.2.0 which we will have out today or tomorrow. If @headius and I can confirm work I think we can retarget this for 9.2.2.0. Seems exactly what we thought was wrong. About the only outcome I could see is if somehow finalization does not run but I am not sure we can be helf accountable for that. It also makes me wonder why it works with older version? They probably also depended on finalization in their version but did it without allowing us to choose when it happens.

@kares

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

okay, will spin a release (jruby-readline 1.3.6) and open a PR for updating version.

kares added a commit to kares/jruby that referenced this issue Nov 7, 2018

update jruby-readline de-ja-vu (for JRuby::Util.load_ext)
on top of jrubyGH-5225 fixes restoring stty after runtime tear-down
resolves jrubyGH-5387

kares added a commit to jruby/jruby-readline that referenced this issue Nov 8, 2018

[fix] another try at restoring terminal settings
since the previous attempt (on runtime tear-down) does not always work

towards getting updates back: jruby/jruby#5387

actually also resolves: jruby/jruby#3181
@kares

This comment has been minimized.

Copy link
Member

commented Nov 8, 2018

another day, another piece (feels like I'm not sure what's going on under the hood with JLine).

so in some cases I got my term restored in others not, must be missing smt obvious ...
... did what I was trying to not do the first place: jruby/jruby-readline#4

esp. since there's stty exec around doing readline, this should make sure stty is properly restored

@enebo enebo modified the milestones: JRuby 9.2.3.0, JRuby 9.2.4.0 Nov 8, 2018

kares added a commit to kares/jruby that referenced this issue Nov 9, 2018

update jruby-readline de-ja-vu (for JRuby::Util.load_ext)
on top of jrubyGH-5225 fixes restoring stty after runtime tear-down
resolves jrubyGH-5387
@kares

This comment has been minimized.

Copy link
Member

commented Nov 9, 2018

false alarm, over ^^^ ... missed a commit where the finalizer got fixed (had it hook up improperly).
we shall start with the simple runtime finalizer fix, the proposed PR is more changing (also more correct).
jruby-readline 1.3.7 is now released and expected to be working with latest jline (restoring stty) ...

kares added a commit to jruby/jruby-readline that referenced this issue Nov 9, 2018

[fix] another try at restoring terminal settings
since the previous attempt (on runtime tear-down) does not always work

towards getting updates back: jruby/jruby#5387

actually also resolves: jruby/jruby#3181

@kares kares closed this in #5433 Nov 13, 2018

kares added a commit that referenced this issue Nov 13, 2018

update jruby-readline de-ja-vu (for JRuby::Util.load_ext) (#5433)
on top of GH-5225 fixes restoring stty after runtime tear-down
resolves GH-5387

@enebo enebo modified the milestones: JRuby 9.2.4.0, JRuby 9.2.5.0 Nov 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.