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

REPL does not show input (Windows) #9434

Closed
scabug opened this issue Aug 12, 2015 · 12 comments
Closed

REPL does not show input (Windows) #9434

scabug opened this issue Aug 12, 2015 · 12 comments

Comments

@scabug
Copy link

scabug commented Aug 12, 2015

After upgrading to Scala 2.11.7 on Windows, the REPL when started using sbt console does not display the user's input when typing anymore. Only after pressing ENTER, one can see the result of evaluating the input (but not the input itself).

I guess this problem is somehow related to [https://github.com/scala/scala/pull/4563], so I addded -Ydebug to scalacOptions. The output seems to confirm that the REPL cannot find the embedded JLine interpreter.

> console
[info] Starting scala interpreter...
[info]
Trying to instantiate a InteractiveReader from scala.tools.nsc.interpreter.jline
.InteractiveReader
Trying to instantiate a InteractiveReader from scala.tools.nsc.interpreter.jline
_embedded.InteractiveReader
All InteractiveReaders tried:
  - scala.tools.nsc.interpreter.jline.InteractiveReader --> java.lang.reflect.In
vocationTargetException
        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:62)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:45)
        java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$76(ILoop.scala:856)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1448/1176529533.apply(Unknown
Source)
        scala.tools.nsc.interpreter.ILoop.mkReader$1(ILoop.scala:862)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$80(ILoop.scala:866)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1447/1284017825.apply(Unknown
Source)
        scala.util.Try$.apply(Try.scala:211)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$79(ILoop.scala:866)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1446/1557843730.apply(Unknown
Source)
        scala.collection.immutable.Stream.map(Stream.scala:418)
        scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:866)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$86(ILoop.scala:907)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$85(ILoop.scala:907)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1436/1142893085.apply$mcZ$sp(U
nknown Source)
        scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
        scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaC
lassLoader.scala:125)
        scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:902)
        scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:927)
        xsbt.ConsoleInterface.run(ConsoleInterface.scala:62)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:62)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
        java.lang.reflect.Method.invoke(Method.java:497)
        sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
        sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:76)
        sbt.Console.sbt$Console$$console0$1(Console.scala:22)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala
:23)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        sbt.Logger$$anon$4.apply(Logger.scala:85)
        sbt.TrapExit$App.run(TrapExit.scala:248)
        java.lang.Thread.run(Thread.java:745)

  - scala.tools.nsc.interpreter.jline_embedded.InteractiveReader --> java.lang.C
lassNotFoundException: scala.tools.nsc.interpreter.jline_embedded.InteractiveRea
der
        java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Class.java:264)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$76(ILoop.scala:855)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1448/1176529533.apply(Unknown
Source)
        scala.tools.nsc.interpreter.ILoop.mkReader$1(ILoop.scala:862)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$80(ILoop.scala:866)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1447/1284017825.apply(Unknown
Source)
        scala.util.Try$.apply(Try.scala:211)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$79(ILoop.scala:866)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1446/1557843730.apply(Unknown
Source)
        scala.collection.immutable.Stream.map(Stream.scala:418)
        scala.collection.immutable.Stream.scala$collection$immutable$Stream$$$an
onfun$5(Stream.scala:418)
        scala.collection.immutable.Stream$$Lambda$1465/891606772.apply(Unknown S
ource)
        scala.collection.immutable.Stream$Cons.tail(Stream.scala:1187)
        scala.collection.immutable.Stream$Cons.tail(Stream.scala:1177)
        scala.collection.immutable.Stream.collect(Stream.scala:435)
        scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:868)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$86(ILoop.scala:907)
        scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$$an
onfun$85(ILoop.scala:907)
        scala.tools.nsc.interpreter.ILoop$$Lambda$1436/1142893085.apply$mcZ$sp(U
nknown Source)
        scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
        scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaC
lassLoader.scala:125)
        scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:902)
        scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:927)
        xsbt.ConsoleInterface.run(ConsoleInterface.scala:62)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:62)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
        java.lang.reflect.Method.invoke(Method.java:497)
        sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
        sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:76)
        sbt.Console.sbt$Console$$console0$1(Console.scala:22)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala
:23)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        sbt.Logger$$anon$4.apply(Logger.scala:85)
        sbt.TrapExit$App.run(TrapExit.scala:248)
        java.lang.Thread.run(Thread.java:745)

What is odd is that the same behavior occurs when starting the REPL directy by running scala inside Cygwin, but not when running scala inside the Windows command line (although the debug output looks the same), whereas the problem occurs under both environments when the REPL is launched from within SBT using console.

@scabug
Copy link
Author

scabug commented Aug 12, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9434?orig=1
Reporter: Michael Ummels (ummels)
Affected Versions: 2.11.7, 2.12.0-M1, 2.12.0-M2

@scabug
Copy link
Author

scabug commented Aug 14, 2015

@som-snytt said:
Just a quick download & trial on the old cygwin setup. I see echo.

$ scala
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_51).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 42
res0: Int = 42

scala> :quit

apm@halyard ~
$ scala -Ydebug
Trying to instantiate a InteractiveReader from scala.tools.nsc.interpreter.jline.InteractiveReader
Trying to instantiate a InteractiveReader from scala.tools.nsc.interpreter.jline_embedded.InteractiveReader
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.NoClassDefFoundError: Could not initialize class scala.tools.fusesource_embedded.jansi.internal.Kernel32
        at scala.tools.fusesource_embedded.jansi.internal.WindowsSupport.getConsoleMode(WindowsSupport.java:50)
        at scala.tools.jline_embedded.WindowsTerminal.getConsoleMode(WindowsTerminal.java:204)
        at scala.tools.jline_embedded.WindowsTerminal.init(WindowsTerminal.java:82)
        at scala.tools.jline_embedded.TerminalFactory.create(TerminalFactory.java:101)
        at scala.tools.jline_embedded.TerminalFactory.get(TerminalFactory.java:158)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:229)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:221)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:209)
        at scala.tools.nsc.interpreter.jline_embedded.JLineConsoleReader.<init>(JLineReader.scala:61)
        at scala.tools.nsc.interpreter.jline_embedded.InteractiveReader.<init>(JLineReader.scala:33)

@scabug
Copy link
Author

scabug commented Aug 20, 2015

Michael Ummels (ummels) said (edited on Aug 20, 2015 4:43:07 PM UTC):
I just started Cygwin using cygwin.bat instead of running "Cygwin Terminal" from the Windows start menu, and indeed I see echo, so the error seems to depend on which shell or terminal you use.

Anyway, could you try runing sbt console in a project with scalaVersion set to 2.11.7? Because when I run the REPL from SBT, I don't see echo even on the regular Windows command line.

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@davidcian
Copy link

I've got the same issue on Windows 10 Family (Version 1803, 17134.471). I'm using sbt 1.2.3, and Scala 2.12.6. When I run sbt inside a git bash console, it does not echo input to the CLI, although it does receive it.

@geekyouth
Copy link

keep watch,me too

@SethTisue
Copy link
Member

is there any evidence this is a bug in scala/scala and not in sbt/sbt? if there isn't, we should close the ticket

@counter2015
Copy link

This could be a bug from sbt.
I found a related issue sbt/sbt#5063, and fixed in sbt/sbt#5295.

@som-snytt
Copy link

Thanks for the heads up, @counter2015

@SethTisue OP said it happened under cygwin with vanilla scala command. That suggests jline something. (I tested cygwin above, but I no longer have a working cygwin setup.)

Maybe the question is does it happen with jline 3. Then maybe we'll understand the workaround, which may be something like "don't do this in your .inputrc" or ".jlinerc".

I can't tell at a glance if the sbt fix applies. Our console.Reader certainly gets the terminal size, etc. It couldn't hurt.

Oh I see @counter2015 was on Ubuntu under Windows. I can actually try that out. Certainly I've been using scala REPL there for a year with no problem. I do have a problem where opening a couple of Ubuntu windows fails with the symptom that hitting enter opens a new window.

@counter2015
Copy link

I just tried scala 2.13.2 REPL and it does not show input in Windows10 Family Version 1909.
1

However, in 2.13.1 it works
GIF1

@SethTisue
Copy link
Member

SethTisue commented Apr 27, 2020

@counter2015 can I ask you to open a new ticket on that? it's conceivable we'll discover some relationship between the two tickets, but this ticket differs from your report in two major respects:

  1. this ticket is about the behavior of sbt console, not scala.bat
  2. this ticket predates Scala 2.13.2, whereas your report is about an apparent regression in 2.13.2

so I think it's best if we track them separately

@counter2015
Copy link

@SethTisue ok, I will open a new ticket

@SethTisue SethTisue modified the milestones: Backlog, 2.13.2 Apr 29, 2020
@SethTisue
Copy link
Member

the new ticket opened by @counter2015 is #11959

I'm closing this ticket on the hopeful assumption that there aren't any other problems as of 2.13.2

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

No branches or pull requests

6 participants