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

fragile detection of windows console, and bad REPL experience in cygwin #669

Closed
philwalk opened this issue May 10, 2021 · 5 comments
Closed

Comments

@philwalk
Copy link

This problem is described in some detail here: scala/scala3#12405.

There are two separate (inter-related) problems:

  1. a CMD session is incorrectly identified as a cygwin session if PWD=/Users (for example)
  2. a cygwin session, although correctly identified in org.jline.utils.OSUtils, is unusable

The 2nd problem has no easy workaround, other than to trick jline3 into mis-identifying the environment.
Without knowing what the root cause is, so I can't say whether the fix will be in jline3 or in scala3.

Here's what a failed REPL session looks like:

philwalk@d5:/opt/ue
$ scala
←[?1h←=←[90m~←[0m
←[?2004h←[34mscala> ←[0m

and here's what it should look like:

$ scala
scala> :q
philwalk@d5:/opt/ue
@mattirn
Copy link
Collaborator

mattirn commented May 11, 2021

@philwalk thanks for rising issue. Please could you check if the pull request #670 fixes your problem 2.

@gnodet
Copy link
Member

gnodet commented May 11, 2021

@mattirn I've been look at windows since a few days for another purpose.
I found out that on Cygwin 3.0.x (and maybe 3.1.x), the Jansi support is broken (because the windows console is hidden in a similar way than when using git bash / msys). It's working on Cygwin 2.x and 3.2.x. The ExecPty does not really work either (the NonBlockingInputStream seems to block, in a similar way than on WSL, though the jansi posix support works on WSL).
In theory, we should have Jansi posix support on Cygwin / MSYS, however, I can't find out a way to build the DLL correctly.

@philwalk
Copy link
Author

philwalk commented May 12, 2021

@philwalk thanks for rising issue. Please could you check if the pull request #670 fixes your problem 2.
I just looked at the changes, and one concern is that a similar problem exists with some combinations of Terminal & Shell, whereas the changes seem to only affect cygwin. However, I will run some tests on #670, hopefully in a day or two.

BTW, here's what the build output looks like on my |Windows Terminal| cygwin console:

$uname -a
CYGWIN_NT-10.0 d5 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin
$./build rebuild
[snip ...]
[[1;34mINFO[m]
[[1;34mINFO[m] JLine Parent 3.17.2-SNAPSHOT ....................... [1;32mSUCCESS[m [  9.259 s]
[[1;34mINFO[m] JLine Terminal ..................................... [1;32mSUCCESS[m [ 13.377 s]
[[1;34mINFO[m] JLine JNA Terminal ................................. [1;32mSUCCESS[m [  5.785 s]
[[1;34mINFO[m] JLine JANSI Terminal ............................... [1;32mSUCCESS[m [  5.255 s]
[[1;34mINFO[m] JLine Reader ....................................... [1;32mSUCCESS[m [ 11.495 s]
[[1;34mINFO[m] JLine Style ........................................ [1;32mSUCCESS[m [  5.180 s]
[[1;34mINFO[m] JLine Builtins ..................................... [1;32mSUCCESS[m [ 39.108 s]
[[1;34mINFO[m] JLine Console ...................................... [1;32mSUCCESS[m [  7.091 s]
[[1;34mINFO[m] JLine Groovy ....................................... [1;32mSUCCESS[m [  6.536 s]
[[1;34mINFO[m] JLine Remote SSH ................................... [1;32mSUCCESS[m [  3.166 s]
[[1;34mINFO[m] JLine Remote Telnet ................................ [1;32mSUCCESS[m [  3.355 s]
[[1;34mINFO[m] JLine Bundle ....................................... [1;32mSUCCESS[m [ 19.236 s]
[[1;34mINFO[m] JLine Demo ......................................... [1;32mSUCCESS[m [  3.319 s]
[[1;34mINFO[m] JLine Graal Demo 3.17.2-SNAPSHOT ................... [1;32mSUCCESS[m [  2.875 s]
[[1;34mINFO[m] [1m------------------------------------------------------------------------←[m
[[1;34mINFO[m] [1;32mBUILD SUCCESS[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------←[m
[[1;34mINFO[m] Total time: 02:15 min
[[1;34mINFO[m] Finished at: 2021-05-12T11:17:21-06:00
[[1;34mINFO[m] [1m------------------------------------------------------------------------←[m

In Windows Terminal, everything looks good, arrow keys and color output looks good in each of these:

CYGWIN_NT-10.0 d5 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin
MINGW64_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-11-08 12:32 UTC x86_64 Msys
MINGW32_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-11-08 12:32 UTC x86_64 Msys
MSYS_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-11-08 12:32 UTC x86_64 Msys

In ConEmu, problem with cygwin console output, although arrow keys seem to work:

$ uname -a
CYGWIN_NT-10.0 d5 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin
$ scala
[?1h←=←[90m~←[0m
[?2004h[34mscala> [0m:q
[?1l←>←[?2004l
philwalk@d5 /opt/ue

This fixes the arrow keys problem, but not the display, and in addition, our workaround no longer fixes the display problem.
(Windows workaround is to unset MSYSTEM and PWD)

WRT ConEmu and MINGW64_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-10-23 13:08 UTC x86_64 Msys:

  • arrow keys don't work
  • display has funky characters

For ConEmu and MINGW32_NT-6.2 D5 1.0.19(0.48/3/2) 2016-07-13 17:45 i686 Msys:

May 12, 2021 12:03:41 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
scala> 1 |[A
  |  ^
  |  ']' expected, but eof found

May 12, 2021 12:03:43 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
scala> Exception in thread "main" java.lang.NullPointerException
        at dotty.tools.repl.JLineTerminal.close(JLineTerminal.scala:75)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:149)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:114)
        at dotty.tools.repl.Main$.main(Main.scala:6)
        at dotty.tools.repl.Main.main(Main.scala)

With ConEmu and MSYS_NT-10.0-19042 d5 3.1.7-340.x86_64 2020-11-08 12:32 UTC x86_64 Msy:
Everything looks good with old jars or with new, and with or without workaround (!?).

Manual testing this stuff is a bit tedious, as you know, hopefully I haven't reported anything incorrectly.

@mvmn
Copy link

mvmn commented Sep 10, 2021

Tested PR 670 locally via ./demo/jline-repl.sh jansi - the issue in CygWin appears to be fixed

@gnodet
Copy link
Member

gnodet commented Sep 16, 2021

It would be nice to check with a few older cygwin versions to make sure it also works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants