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 3.6.4-RC1, 3.6.3, 2.13.15, 2.13.16 gives error when exit with Ctrl+D or :quit #22427

Open
bjornregnell opened this issue Jan 21, 2025 · 13 comments

Comments

@bjornregnell
Copy link
Contributor

Compiler version

Scala 3.6.3, 2.13.15, 2.13.16 under Ubuntu 22.04

Minimized code

$ uname -v
#49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov  6 17:42:15 UTC 2
bjornr@bjornix:~
$ scala -S 3.6.3
Welcome to Scala 3.6.3 (21.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                
scala> 
stty: 'standard input': unable to perform all requested operations
bjornr@bjornix:~
$ scala -S 2.13.16
Downloading Scala 2.13.16 compiler
Downloading Scala 2.13.16 bridge
Welcome to Scala 2.13.16 (OpenJDK 64-Bit Server VM, Java 21.0.5).
Type in expressions for evaluation. Or try :help.

scala> 
:quit
stty: 'standard input': unable to perform all requested operations
bjornr@bjornix:~
$ scala -S 2.13.15
Welcome to Scala 2.13.15 (OpenJDK 64-Bit Server VM, Java 21.0.5).
Type in expressions for evaluation. Or try :help.

scala> 
:quit
stty: 'standard input': unable to perform all requested operations
bjornr@bjornix:~
$ 

Output

stty: 'standard input': unable to perform all requested operations

Expectation

No error.

@bjornregnell bjornregnell added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 21, 2025
@bjornregnell
Copy link
Contributor Author

It does work for 2.13.13 and 3.6.2

Image

@SethTisue
Copy link
Member

SethTisue commented Jan 21, 2025

Scala 2.13.14 was when we upgraded JLine from 3.24 to 3.25 (scala/scala#10717); Scala 2.13.16 has JLine 3.27.1

but it's puzzling that that doesn't seem to line up with what you're seeing on the Scala 3 side. 3.6.2 had JLine 3.27.0, 3.6.3 has JLine 3.27.1

are there other Linux users watching the repo who could report if they see this on the same set of versions? it's possible this is somehow dependent on some detail of how Björn's terminal is configured

I'm also curious if it only happens when the REPL is launched by Scala-CLI, or whether it also happens using the old runner (in either 2 or 3)

I don't see anything relevant at https://github.com/jline/jline3

@OndrejSpanel
Copy link
Member

I have tried this on fresh installed Ubuntu 24 in WSL with Java 17, got no error both with Ctrl-D and :quit:

ondra@OndronWork:~$ scala
Warning: JAVA_HOME environment variable is not set.
Welcome to Scala 3.6.3 (17.0.13, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> :quit
ondra@OndronWork:~$

@bjornregnell
Copy link
Contributor Author

I don't have any special settings in my terminal but it seems specific to Ubuntu 22.04, as I don't get it on 18.04 or 20.04. And I don't get the warning that JAVA_HOME is not set that @OndrejSpanel got.

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Jan 22, 2025

Anyone with Ubuntu 22.04 that gets the same error when quitting the 3.6.3 repl?

stty: 'standard input': unable to perform all requested operations

but it's puzzling that that doesn't seem to line up with what you're seeing on the Scala 3 side. 3.6.2 had JLine 3.27.0, 3.6.3 has JLine 3.27.1

@SethTisue Maybe I was switching machines and confusing version. I'll verify again when I get to my 22.04 machine (currently out of office).

@SethTisue
Copy link
Member

@bjornregnell thanks. it would be good to have additional confirmation, since I really would expect it to stem from the JLine version

@Gedochao Gedochao added stat:needs info and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 23, 2025
@spamegg1
Copy link

spamegg1 commented Jan 23, 2025

are there other Linux users watching the repo who could report if they see this on the same set of versions? it's possible this is somehow dependent on some detail of how Björn's terminal is configured

I cannot reproduce on 3.6.3 or 2.13.16. Ubuntu 24.04 using zsh on Kitty terminal emulator. Also cannot reproduce using bash on Gnome Terminal emulator.

@philwalk
Copy link
Contributor

philwalk commented Jan 23, 2025

For what it's worth, the following may not be related, although it shares an stty error message

I've been meaning to file a bug on what appears to be a related issue, caused by calling stty on a non-terminal.
It only seems to occur for me with Windows shell environments, like cygwin, git-bash, msys64, etc.

Here's a script that produces a similar error message:

#!/opt/scala3-3.6.3-x86_64-pc-win32/bin/scala
import scala.collection.Iterator

val lines = for {
  line <- Iterator.continually(scala.io.StdIn.readLine()).takeWhile( _ != null )
  if line != null
} yield line
printf("%d lines\n", lines.size)

Here's how to demonstrate the error message:

philwalk@d5 MINGW64 /opt/ue
# ls -l | jsrc/readStdin.sc
stty: 'standard input': Inappropriate ioctl for device
Compiling project (Scala 3.6.3, JVM (17))
Compiled project (Scala 3.6.3, JVM (17))
837 lines

A fix is to add a tty check to bin/common or to /opt/scala3-3.6.3-x86_64-pc-win32/libexec/common-shared:

#!/usr/bin/env bash

if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then
  isterminal=1
  # save terminal settings
  saved_stty=$(stty -g 2>/dev/null)
  # clear on error so we don't later try to restore them
  if [[ ! $? ]]; then
    saved_stty=""
  fi
else
  isterminal=0
fi

I believe this is a long-standing scala3 bug.

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Jan 24, 2025

I have three different machines with Ubuntu 22.04 on which it surfaces (but all my 18.04 and 20.04 machines give no error (I have too many machines...)).

I'm using the standard terminal and the terminal is not tweaked with any special setting. You can see all version of Scala 3 and 2 that I tried and it works again back in
3.6.2 and 2.13.13
. Hope this helps? @SethTisue

Image

@OndrejSpanel
Copy link
Member

OndrejSpanel commented Jan 24, 2025

I confirm the issue on a freshly installed Ubuntu 22 on VMWare Workstation virtual machine (Windows 11 x64 host):

ondra@ondron-ubuntu:~$ uname -v
#52~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Dec  9 15:00:52 UTC 2
ondra@ondron-ubuntu:~$ scala -S 3.6.3
Welcome to Scala 3.6.3 (21.0.6, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                
scala> 
stty: 'standard input': unable to perform all requested operations
ondra@ondron-ubuntu:~$ 

The issue is not seen with 3.6.2 - but this version shows a warning about terminal provider jna to me:

ondra@ondron-ubuntu:~$ scala -S 3.6.2
Jan 24, 2025 11:44:20 AM org.jline.utils.Log logr
WARNING: The terminal provider jna has been deprecated, check your configuration. This warning can be disabled by setting the system property org.jline.terminal.disableDeprecatedProviderWarning to true.
Welcome to Scala 3.6.2 (21.0.6, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                
scala> 
ondra@ondron-ubuntu:~$ 

@OndrejSpanel
Copy link
Member

OndrejSpanel commented Jan 24, 2025

but it's puzzling that that doesn't seem to line up with what you're seeing on the Scala 3 side. 3.6.2 had JLine 3.27.0, 3.6.3 has JLine 3.27.1

Scala 3 jline

I can confirm this:

Welcome to Scala 3.6.2 (21.0.6, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                
scala> System.getProperty("java.class.path").split("/").filter(_.contains("jline"))
val res0: Array[String] = Array(jline, jline-reader, jline-reader-3.27.0.jar:, jline, jline-terminal, jline-terminal-3.27.0.jar:, jline, jline-terminal-jna, jline-terminal-jna-3.27.0.jar:, jline, jline-native, jline-native-3.27.0.jar:)
                                                                                
scala> 
ondra@ondron-ubuntu:~$ scala -S 3.6.3
Welcome to Scala 3.6.3 (21.0.6, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                
scala> System.getProperty("java.class.path").split("/").filter(_.contains("jline"))
val res0: Array[String] = Array(jline, jline-reader, jline-reader-3.27.1.jar:, jline, jline-terminal, jline-terminal-3.27.1.jar:, jline, jline-terminal-jni, jline-terminal-jni-3.27.1.jar:, jline, jline-native, jline-native-3.27.1.jar)
                                                                                
scala> 
stty: 'standard input': unable to perform all requested operations
ondra@ondron-ubuntu:~$ 

Scala 2.13 jline

As for 2.13 versions, I see the issue with all of 2.13.14-16

Scala 2.13.14 was when we upgraded JLine from 3.24 to 3.25 (scala/scala#10717); Scala 2.13.16 has JLine 3.27.1

What is see in the classpath of Scala 2.13 versions in CLI is:

  • Scala 2.13.16: jline-3.27.1-jdk8.jar
  • Scala 2.13.15: jline-3.26.3.jar
  • Scala 2.13.14: jline-3.25.1.jar
ondra@ondron-ubuntu:~$ scala -S 2.13.14
Welcome to Scala 2.13.14 (OpenJDK 64-Bit Server VM, Java 21.0.6).
Type in expressions for evaluation. Or try :help.

scala> 
:quit
stty: 'standard input': unable to perform all requested operations
ondra@ondron-ubuntu:~$ scala -S 2.13.15
Welcome to Scala 2.13.15 (OpenJDK 64-Bit Server VM, Java 21.0.6).
Type in expressions for evaluation. Or try :help.

scala> 
:quit
stty: 'standard input': unable to perform all requested operations
ondra@ondron-ubuntu:~$ scala -S 2.13.16
Welcome to Scala 2.13.16 (OpenJDK 64-Bit Server VM, Java 21.0.6).
Type in expressions for evaluation. Or try :help.

scala> 
:quit
stty: 'standard input': unable to perform all requested operations
ondra@ondron-ubuntu:~$ 

@OndrejSpanel
Copy link
Member

Note the class path is quite different for Scala 2 / Scala 3. In Scala 3 there are jni / jna listed, which are not present in the 2.13 classpath:

ondra@ondron-ubuntu:~$ scala -S 2.13.16
Welcome to Scala 2.13.16 (OpenJDK 64-Bit Server VM, Java 21.0.6).
Type in expressions for evaluation. Or try :help.

scala> System.getProperty("java.class.path").split("/").filter(_.contains("jline"))
val res0: Array[String] = Array(jline, jline, jline-3.27.1-jdk8.jar)

scala> 

@bjornregnell bjornregnell changed the title repl 3.6.3, 2.13.15, 2.13.16 gives error when exit with Ctrl+D repl 3.6.4-RC1, 3.6.3, 2.13.15, 2.13.16 gives error when exit with Ctrl+D Jan 24, 2025
@bjornregnell bjornregnell changed the title repl 3.6.4-RC1, 3.6.3, 2.13.15, 2.13.16 gives error when exit with Ctrl+D repl 3.6.4-RC1, 3.6.3, 2.13.15, 2.13.16 gives error when exit with Ctrl+D or :quit Jan 24, 2025
@OndrejSpanel
Copy link
Member

OndrejSpanel commented Jan 24, 2025

More accurate class-path dump using System.getProperty("java.class.path").split(':').filter(_.split('/').contains("jline")):

3.6.3:

val res0: Array[String] = Array(/home/ondra/.sdkman/candidates/scala/current/maven2/org/jline/jline-reader/3.27.1/jline-reader-3.27.1.jar, /home/ondra/.sdkman/candidates/scala/current/maven2/org/jline/jline-terminal/3.27.1/jline-terminal-3.27.1.jar, /home/ondra/.sdkman/candidates/scala/current/maven2/org/jline/jline-terminal-jni/3.27.1/jline-terminal-jni-3.27.1.jar, /home/ondra/.sdkman/candidates/scala/current/maven2/org/jline/jline-native/3.27.1/jline-native-3.27.1.jar)
  • org/jline/jline-reader/3.27.1/jline-reader-3.27.1.jar
  • org/jline/jline-terminal/3.27.1/jline-terminal-3.27.1.jar
  • org/jline/jline-terminal-jni/3.27.1/jline-terminal-jni-3.27.1.jar
  • org/jline/jline-native/3.27.1/jline-native-3.27.1.jar

3,6,2:

val res0: Array[String] = Array(/home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-reader/3.27.0/jline-reader-3.27.0.jar, /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal/3.27.0/jline-terminal-3.27.0.jar, /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal-jna/3.27.0/jline-terminal-jna-3.27.0.jar, /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-native/3.27.0/jline-native-3.27.0.jar)
  • org/jline/jline-reader/3.27.0/jline-reader-3.27.0.jar
  • org/jline/jline-terminal/3.27.0/jline-terminal-3.27.0.jar
  • org/jline/jline-terminal-jna/3.27.0/jline-terminal-jna-3.27.0.jar
  • org/jline/jline-native/3.27.0/jline-native-3.27.0.jar

Note 2.13 classpath contains just a single jline entry:

2.13.16:

val res0: Array[String] = Array(/home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1-jdk8.jar)

The value changes for different 2.13 versions:

  • 2.13.16: /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1-jdk8.jar
  • 2.13.15: /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline/3.26.3/jline-3.26.3.jar
  • 2.13.14: /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline/3.25.1/jline-3.25.1.jar
  • 2.13.13: /home/ondra/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline/3.24.1/jline-3.24.1.jar

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