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

scala-cli repl --watch/restart crashes after recompiling sources #2851

Open
josefwegner opened this issue Apr 12, 2024 · 0 comments
Open

scala-cli repl --watch/restart crashes after recompiling sources #2851

josefwegner opened this issue Apr 12, 2024 · 0 comments
Labels
bug Something isn't working REPL Issues tied with the repl sub-command.

Comments

@josefwegner
Copy link

Version(s)
Scala CLI version: 1.2.2

Describe the bug
Exiting a repl session with CTRL-C or :exit crashes after re-compiling changed sources

To Reproduce

 mkdir test
 cd test
 echo '@main def hello: Unit =\n    println("Hello, world\\n")' > hello.scala
 scala-cli repl --watch .

Exit the repl with CTRL-C results in following error message:

Exception in thread "main" com.sun.jna.LastErrorException: [5] Eingabe-/Ausgabefehler
        at com.sun.jna.Native.invokeVoid(Native Method)
        at com.sun.jna.Function.invoke(Function.java:415)
        at com.sun.jna.Function.invoke(Function.java:361)
        at com.sun.jna.Library$Handler.invoke(Library.java:265)
        at jdk.proxy1/jdk.proxy1.$Proxy0.tcsetattr(Unknown Source)
        at org.jline.terminal.impl.jna.linux.LinuxNativePty.doSetAttr(LinuxNativePty.java:89)
        at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:29)
        at org.jline.terminal.impl.AbstractPosixTerminal.doClose(AbstractPosixTerminal.java:76)
        at org.jline.terminal.impl.PosixSysTerminal.doClose(PosixSysTerminal.java:95)
        at org.jline.terminal.impl.AbstractTerminal.close(AbstractTerminal.java:98)
        at dotty.tools.repl.JLineTerminal.close(JLineTerminal.scala:78)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:174)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:135)
        at dotty.tools.repl.Main$.main(Main.scala:7)
        at dotty.tools.repl.Main.main(Main.scala)

Same exceptions happens a bit later when you exit the repl with :exit and changing the source file:

scala-cli repl --watch .
Welcome to Scala 3.4.1 (17.0.10, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                           
scala> :exit
Watching sources, press Ctrl+C to exit, or press Enter to re-run.
Compiling project (Scala 3.4.1, JVM (17))
Compiled project (Scala 3.4.1, JVM (17))
Welcome to Scala 3.4.1 (17.0.10, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala>

After pressing any key, you get the exception:

Exception in thread "main" com.sun.jna.LastErrorException: [5] Eingabe-/Ausgabefehler
        at com.sun.jna.Native.invokeVoid(Native Method)
        at com.sun.jna.Function.invoke(Function.java:415)
        at com.sun.jna.Function.invoke(Function.java:361)
        at com.sun.jna.Library$Handler.invoke(Library.java:265)
        at jdk.proxy1/jdk.proxy1.$Proxy0.tcsetattr(Unknown Source)
        at org.jline.terminal.impl.jna.linux.LinuxNativePty.doSetAttr(LinuxNativePty.java:89)
        at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:29)
        at org.jline.terminal.impl.AbstractPosixTerminal.doClose(AbstractPosixTerminal.java:76)
        at org.jline.terminal.impl.PosixSysTerminal.doClose(PosixSysTerminal.java:95)
        at org.jline.terminal.impl.AbstractTerminal.close(AbstractTerminal.java:98)
        at dotty.tools.repl.JLineTerminal.close(JLineTerminal.scala:78)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:174)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:135)
        at dotty.tools.repl.Main$.main(Main.scala:7)
        at dotty.tools.repl.Main.main(Main.scala)

Expected behaviour
Repl should properly restart after recompiling the project.

Running ammonite instead of the default repl does not have the same issue. Ammonite restarts properly after recompiling the code. But the input is messed up, you need to press the same key multiple times until it is printed in the repl.

@josefwegner josefwegner added the bug Something isn't working label Apr 12, 2024
@Gedochao Gedochao added the REPL Issues tied with the repl sub-command. label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working REPL Issues tied with the repl sub-command.
Projects
None yet
Development

No branches or pull requests

2 participants