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 eagerly sets -java-output-version not understood by scalac #2126

Closed
som-snytt opened this issue May 18, 2023 · 2 comments · Fixed by #2321
Closed

scala-cli eagerly sets -java-output-version not understood by scalac #2126

som-snytt opened this issue May 18, 2023 · 2 comments · Fixed by #2321
Assignees
Labels
bug Something isn't working

Comments

@som-snytt
Copy link

Version(s)
Scala CLI version: 1.0.0-RC2
Scala version (default): 3.2.2

Describe the bug
Today I was resolved to try scala-cli again, so I zapped my caches, followed the getting started on scala-lang, googled for scala-cli docs because I saw an announcement recently about the latest version, kind of finally found the virtuslab blog, though not the recent announcement I thought I remembered.

This is to say, I was surprised there was still more than one step to start using scala-cli, which I will use often because the FOMO was killing me.

Trying the trivial pwd example requires tweaks, but the hard part is having to downgrade my ambient JDK or install via --jvm 19.

To Reproduce

➜  snips scala-cli pwd.sc
Compiling project (Scala 3.2.2, JVM)
Error: 20 is not a valid choice for -java-output-version
  scalac -help  gives more information
Error compiling project (Scala 3.2.2, JVM)
Compilation failed

It still fails if I add

//> using option -java-output-version:19

Expected behaviour
It would be nicer not to specify the compiler option, which ought to default to what is natural.

Unfortunately, scalac doesn't report its default:

 -java-output-version  Compile code with classes specific to the given version of the Java platform available on the
                       classpath and emit bytecode for this version. Corresponds to -release flag in javac.
                       Choices 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19

Scala 2 does the obvious and uses the obvious option name:

  -release:<release>           Compile for a version of the Java API and target class file. (8,9,10,11,12,13,14,15,16,17,18,19,[20])
@som-snytt som-snytt added the bug Something isn't working label May 18, 2023
@som-snytt
Copy link
Author

I encountered this again today while evangelizing at scala/scala3#18107

@lwronski
Copy link
Contributor

lwronski commented Jul 7, 2023

Hi @som-snytt, thanks for reporting. Scala CLI uses the -release option, which is now aliased to -java-output-version for backward compatibility with older Scala versions.

Setting -release 19 should solve the issue, allowing you to override the default value:

//> using option -release 19

I think that if users pass //> using option -java-output-version:19, scala-cli should override the default for --release options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants