scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

JLine version is outdated

Open SethTisue opened this issue 1 year ago • 4 comments

Dotty is still on 3.19.0, from way back in 2021.

(Scala 2.13.13 is on 3.24.1, and we'll very likely move to 3.25.1 in 2.13.14.)

Why is the upgrade desirable? No specific killer reason that I'm aware of, but the JLine folks are always fixing bugs, especially for Windows users. There have a been a lot of bug fixes since 3.19.0. Also, we should align with Scala 2; users shouldn't have to wonder if differences in REPL behavior stem from the JLine versions being out of sync.

SethTisue avatar Feb 15 '24 21:02 SethTisue

Unfortunately it's not as simple as bumping the version in project/Build.scala. Doing so breaks the repl task in our sbt build:

[error] java.lang.NoSuchMethodError: 'org.jline.utils.AttributedString org.jline.utils.AttributedString.fromAnsi(java.lang.String, java.util.List, java.lang.String, java.lang.String)'
[error] 	at org.jline.reader.impl.LineReaderImpl.fromAnsi(LineReaderImpl.java:4232)
[error] 	at org.jline.reader.impl.LineReaderImpl.expandPromptPattern(LineReaderImpl.java:4154)
[error] 	at org.jline.reader.impl.LineReaderImpl.setPrompt(LineReaderImpl.java:1253)
[error] 	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:628)
[error] 	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:512)
[error] 	at dotty.tools.repl.JLineTerminal.readLine(JLineTerminal.scala:75)

The cause is that sbt itself is still on 3.19.0, as per https://github.com/sbt/sbt/issues/7177 . On that ticket, @eed3si9n writes:

I don't think there's good solution for now

If console could fork, that would probably solve it, but that's not supported by sbt, as per https://github.com/sbt/sbt/issues/1918

Perhaps we could reimplement repl on top of runMain, rather than on top of console...? With runMain, we could fork.

SethTisue avatar Feb 15 '24 21:02 SethTisue

A natural question is: Isn't Scala 2 affected? Could Scala 3 do the same thing?

In the Scala 2 build, the scala command in our sbt build (which runs the REPL when run with no arguments) is implemented on runMain. But we've got a different problem: the REPL runs, but many JLine features don't work, as per https://github.com/scala/scala-dev/issues/755

The workaround (as described on that ticket) is to launch the REPL from the shell rather than from sbt, but that's unsatisfying. Dale and I tried to fix it once; our abandoned attempt is at https://github.com/scala/scala/pull/9380

SethTisue avatar Feb 15 '24 21:02 SethTisue

PR by @hamzaremmal: https://github.com/lampepfl/dotty/pull/19744

SethTisue avatar Feb 21 '24 00:02 SethTisue

sbt itself is still on 3.19.0

Eugene has pointed out that sbt 1.10.0-M1 has taken the 3.24.1 upgrade. I will try to further bump it to 3.25.1: https://github.com/sbt/sbt/pull/7500

SethTisue avatar Feb 21 '24 00:02 SethTisue

@Kordyjan @Gedochao I think it will be worth mentioning in the release notes for the versions where the JLine upgrade lands that sbt users will need to upgrade to 1.9.9 in order to continue using the console task to access the REPL; see https://github.com/scala/scala-dev/pull/861 for sample wording

SethTisue avatar Feb 26 '24 18:02 SethTisue

I've added the release-notes label to the PR to flag it.

hamzaremmal avatar Feb 26 '24 20:02 hamzaremmal