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 2.13 REPL has no color on Windows #3394

Closed
Friendseeker opened this issue Dec 23, 2024 · 13 comments
Closed

Scala 2.13 REPL has no color on Windows #3394

Friendseeker opened this issue Dec 23, 2024 · 13 comments
Labels
blocked upstream Issues and changes blocked by something in an external project. bug Something isn't working REPL Issues tied with the repl sub-command. windows Windows-specific issues

Comments

@Friendseeker
Copy link

Friendseeker commented Dec 23, 2024

Version(s)
1.5.4

Describe the bug
Scala 2.13 REPL has no color on Windows

image

To Reproduce
scala-cli -S 2.13.15

Expected behaviour
Output should be colored, like sbt console

image

c.c. @SethTisue

@Friendseeker Friendseeker added the bug Something isn't working label Dec 23, 2024
@Gedochao Gedochao added windows Windows-specific issues REPL Issues tied with the repl sub-command. labels Dec 30, 2024
@Gedochao
Copy link
Contributor

@SethTisue @lrytz @philwalk any clue where to look?

@SethTisue
Copy link
Contributor

I wish I had some insight, but I don't.

@philwalk
Copy link
Contributor

philwalk commented Jan 6, 2025

I verified that the problem exists in cygwin64 running with mintty, and msys64 running in Windows Terminal.
I'll experiment with it to see if I can get any insights.

@philwalk
Copy link
Contributor

philwalk commented Jan 6, 2025

This "feature" seems to be part of scala 2.13 rather than scala-cli (same thing happens in any scala 2.13 REPL session).

The following fix works for me when running either bash or CMD from Windows Terminal:

scala-cli -S 2.13 -Dscala.color=true

When directly running in a CMD session, the following works:

C:\opt\scala-2.13.15\bin>scala-cli -S 2.13 -Dscala.color=true -Djline.terminal=jline.WindowsTerminal

Not sure if these settings could easily be made to be the defaults in those environments.

image

This works in a cygwin mintty session:
image

and in a Windows Terminal msys64 bash session:
image

@SethTisue
Copy link
Contributor

SethTisue commented Jan 7, 2025

note that scala.color defaults to auto

but in src/library/scala/util/Properties.scala I see:

  private[scala] def coloredOutputEnabled: Boolean = propOrElse("scala.color", "auto") match {
    case "auto" => !isWin && consoleIsTerminal
    case s      => "" == s || "true".equalsIgnoreCase(s)
  }

note that the !isWin, which appears to be the culprit

the history for why this was added is at scala/scala#5663 , which was back in 2017, in 2.12.x days

presumably a Scala 2.13 PR doing something better — not just in the Scala-CLI context — would have a good chance of being accepted

about the native-code angle, we've been on JLine 3 on 2.13.x for ages now, and scala/scala#10898 aligns us with the JLine 3 project's current recommendations on Windows

I'm less confident that makes sense to consider changing 2.12, since with every year that passes we're less and less willing to touch 2.12 (which still uses JLine 2) — in general, but especially when it's something like the REPL that's fragile and requires manual testing

@Gedochao
Copy link
Contributor

Gedochao commented Jan 8, 2025

@SethTisue to confirm, is this something we should try to address in the Scala 2.13 (or less likely 2.12) REPL, rather than on the side of Scala CLI? Is there a ticket on Scala 2 side to track this, or should we raise one?

Adding -Dscala.color=true by default for REPL on Windows environments for Scala 2.x specifically in Scala CLI is something we could do, I guess... But maybe it's better to fix it at the source.

@SethTisue
Copy link
Contributor

SethTisue commented Jan 8, 2025

Agree. @Friendseeker @philwalk can I interest you in opening a ticket in scala/bug?

@philwalk
Copy link
Contributor

philwalk commented Jan 8, 2025 via email

@philwalk
Copy link
Contributor

philwalk commented Jan 8, 2025

@philwalk can I interest you in opening a ticket in scala/bug?

I'll look into it. Not familiar with the build process for scala 2, but how hard can it be :)
If we change the default from "auto" to "true", people can do -Dscala.color=false if they run into problems.

@SethTisue
Copy link
Contributor

SethTisue commented Jan 8, 2025

If we change the default from "auto" to "true", people can do -Dscala.color=false if they run into problems

I agree that a PR with only that change might well be accepted, assuming that you show the same manual testing that you showed above

@philwalk
Copy link
Contributor

philwalk commented Jan 9, 2025

Here's the bug report: scala/bug#13077

@philwalk
Copy link
Contributor

philwalk commented Jan 9, 2025

I'm not sure why I seemed to need -Djline.terminal=jline.WindowsTerminal a few days ago, I can't reproduce it, so I assume it was confusion on my part.
The scala 2.13 PR scala/bug#13077 seems to resolve the issue.

@Gedochao Gedochao added the blocked upstream Issues and changes blocked by something in an external project. label Jan 15, 2025
@Gedochao
Copy link
Contributor

Closing this, nothing to do on Scala CLI side.

@Gedochao Gedochao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked upstream Issues and changes blocked by something in an external project. bug Something isn't working REPL Issues tied with the repl sub-command. windows Windows-specific issues
Projects
None yet
Development

No branches or pull requests

4 participants