rascal
rascal copied to clipboard
Rascal REPL does not work when run from git bash
Describe the bug
When the Rascal repl is started from git bash it starts but it never accepts input.
To Reproduce
Start Rascal from git bash:
$ java -jar rascal-shell-stable.jar
Version: 0.33.8
INFO: detected |lib://rascal| at |jar+file:///C:/Users/pieter/rascal/rascal-shell-stable.jar!/|
rascal>
Input can be typed but it is ignored by the REPL. CPU spikes because of an endless loop. Here the root cause is discussed: https://github.com/jline/jline2/issues/245
jstack
shows a similar stack trace compared to the one in the jline issue above.
Possible fixes
One of the solutions suggested there works partially:
When starting Rascal like this: java -Djline.terminal=jline.UnixTerminal -jar rascal-shell-stable.jar
, Rascal no longer hangs. You can interact with the REPL. Unfortunately the cursor keys do not go through the command line history but instead navigate over the screen. So this is only a partial solution.
The final solution seems to be to upgrade from jline2 to jline3 but that is a non-trivial operation because of the API changes in jline3.
I've seen this before with different programs. It has to do with how Git Bash works I think. If you prefix the command with winpty
it starts working.
Thanks @JJWTimmer, that trick works!
To reproduce it, I just installed git for windows inside a Windows Sandbox, the installer warns you about this issue.
there is also this experimental addition for this:
if I leave that disabled: I can indeed reproduce the problem. and running it with winpty indeed fixes it.
if you do choose to turn on that experimental flag, it works without winpty (as the tool tries to figure it out automatically).
in the end, we have to move to jline3, but like you already noted, that's not that trivial. but more than just this bug, we should move to jline3 at some point.