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

JLine version is outdated #19704

Closed
SethTisue opened this issue Feb 15, 2024 · 6 comments · Fixed by #19744
Closed

JLine version is outdated #19704

SethTisue opened this issue Feb 15, 2024 · 6 comments · Fixed by #19744
Assignees
Milestone

Comments

@SethTisue
Copy link
Member

SethTisue commented Feb 15, 2024

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 SethTisue added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 15, 2024
@SethTisue
Copy link
Member Author

SethTisue commented Feb 15, 2024

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 sbt/sbt#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 sbt/sbt#1918

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

@SethTisue
Copy link
Member Author

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 scala/scala-dev#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 scala/scala#9380

@SethTisue
Copy link
Member Author

SethTisue commented Feb 21, 2024

PR by @hamzaremmal: #19744

@SethTisue
Copy link
Member Author

SethTisue commented Feb 21, 2024

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: sbt/sbt#7500

@hamzaremmal hamzaremmal linked a pull request Feb 21, 2024 that will close this issue
@hamzaremmal hamzaremmal removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Feb 24, 2024
@hamzaremmal hamzaremmal self-assigned this Feb 24, 2024
hamzaremmal added a commit that referenced this issue Feb 26, 2024
Fixes #5755, #19704

Tested locally and the difference in behaviour was observed. I'm not
sure how to test it with the CI, if anybody has an idea, please let me
know. Also, this issue might be a problem sbt/sbt#7177


Tested as follow:
- Observe that the issue in `3.4.1-RC1`
```scala
scala-cli repl -S 3.4.1-RC1
Welcome to Scala 3.4.1-RC1 (17.0.7, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class 😃
// defined class 😃

scala> cclas
-- [E006] Not Found Error: -----------------------------------------------------
1 |clas
  |^^^^
  |Not found: clas - did you mean caps?
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala>
```
- Publish dotty locally with the correct jline version
- Observe that the issue is fixed
```scala
scala-cli repl -S 3.4.2-RC1-bin-SNAPSHOT
Welcome to Scala 3.4.2-RC1-bin-SNAPSHOT-git-174d4c6 (17.0.7, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class 😃
// defined class 😃

scala> clas
-- [E006] Not Found Error: -----------------------------------------------------
1 |clas
  |^^^^
  |Not found: clas - did you mean caps?
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala>
``
@SethTisue
Copy link
Member Author

SethTisue commented Feb 26, 2024

@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 scala/scala-dev#861 for sample wording

@hamzaremmal
Copy link
Member

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

@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants