VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
529 stars 125 forks source link

Don't give confusing hint when using toolkit default #2993

Open bjornregnell opened 1 week ago

bjornregnell commented 1 week ago

Version(s) Please provide the version(s) of Scala CLI that is affected by this bug

Scala CLI 1.3.2 (and eventually 1.4.0 when toolkit is bumped)

Describe the bug When the toolkit version is less than latest and //> using toolkit default is specified then the following hint is given:

image

To Reproduce

@ sdk use scalacli 1.3.2
$ cat hi.scala 
//> using scala 3.4.2
//> using toolkit default
@main def reproduce = println("annoying hint")
$ scala-cli run .
Compiling project (Scala 3.4.2, JVM (17))
Compiled project (Scala 3.4.2, JVM (17))
[hint] ./hi.scala:2:19
[hint] "toolkit is outdated, update to 0.4.0"
[hint]      toolkit 0.2.1 -> 0.4.0
[hint] //> using toolkit default
[hint]                   ^^^^^^^
annoying hint

Expected behaviour A clear and concise description of what you expected to happen.

When specifying //> using toolkit default the intent is to not bother with version and use any stable. If I follow the hint I will nail the version to something specific which is not what I want as my script is then not using the future default when bumped.

The annoying and potentially confusing hint should be silenced if //> using toolkit default is given.

Bonus expectations:

Gedochao commented 1 week ago

There should be a way to ask scala-cli what is the current toolkit version.

@bjornregnell technically, it's in the help.

scala-cli compile --help|grep toolkit
#  --toolkit, --with-toolkit version|default  Add toolkit to classPath (not supported in Scala 2.12), 'default' version for Scala toolkit: 0.4.0, 'default' version for typelevel toolkit: 0.1.23
bjornregnell commented 1 week ago

Maybe nice to have but not urgent: scala-cli --help toolkit

bishabosha commented 1 week ago

I agree - the intent is to use the default bundled with the CLI. This gets more hairy when if the user is using the scala/scala3 distribution, and it lags behind the latest greatest toolkit, but they can't update because there's no new scala release :/

bjornregnell commented 1 week ago

if the user is using the scala/scala3 distribution, and it lags behind the latest greatest toolkit, but they can't update because there's no new scala release :/

Well, the user can then always hardcode the toolkit version... And it should work with any Scala version post 3.3? Or am I missing something?

Gedochao commented 1 week ago

if the user is using the scala/scala3 distribution, and it lags behind the latest greatest toolkit, but they can't update because there's no new scala release :/

Well, the user can then always hardcode the toolkit version... And it should work with any Scala version post 3.3? Or am I missing something?

I think @bishabosha meant that this warning would get even more confusing when encountered in the Scala 3 distribution of Scala CLI, which would inevitably lag behind the latest Scala CLI. i.e. Scala CLI 1.3.2 is bundled in Scala 3.5.0-RC right now. And yeah, I agree, we should try to fix it.

bjornregnell commented 1 week ago

Aha! Thanks for clarification. Yes would be really nice.