Skip to content

Commit 222d60f

Browse files
committed
Add a warning message when launching from scala.
1 parent f4e6761 commit 222d60f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,22 @@ object MainGenericRunner {
266266
run(settings.withExecuteMode(ExecuteMode.Run))
267267
else
268268
run(settings.withExecuteMode(ExecuteMode.Repl))
269+
end run
270+
271+
val ranByCoursierBootstrap =
272+
sys.props.isDefinedAt("coursier.mainJar")
273+
|| sys.props.get("bootstrap.mainClass").filter(_ == "dotty.tools.MainGenericRunner").isDefined
274+
275+
val silenced = sys.props.get("scala.use_legacy_launcher") == Some("true")
276+
277+
if !silenced then
278+
Console.err.println(s"[warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work.")
279+
Console.err.println(s"[warning] Please be sure to update to the Scala CLI launcher to use the new features.")
280+
if ranByCoursierBootstrap then
281+
Console.err.println(s"[warning] It appears that your Coursier-based Scala installation is misconfigured.")
282+
Console.err.println(s"[warning] To update to the new Scala CLI runner, please update (coursier, cs) commands first before re-installing scala.")
283+
Console.err.println(s"[warning] Check the Scala 3.5.0 release notes to troubleshoot your installation.")
284+
269285

270286
run(settings) match
271287
case Some(ex: (StringDriverException | ScriptingException)) => errorFn(ex.getMessage)

compiler/test-coursier/dotty/tools/coursier/CoursierScalaTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ object CoursierScalaTests:
166166
case Nil => args
167167
case _ => "--" +: args
168168
val newJOpts = jOpts.map(s => s"--java-opt ${s.stripPrefix("-J")}").mkString(" ")
169-
execCmd("./cs", (s"""launch "org.scala-lang:scala3-compiler_3:${sys.env("DOTTY_BOOTSTRAPPED_VERSION")}" $newJOpts --main-class "$entry" --property "scala.usejavacp=true"""" +: newOptions)*)._2
169+
execCmd("./cs", (s"""launch "org.scala-lang:scala3-compiler_3:${sys.env("DOTTY_BOOTSTRAPPED_VERSION")}" $newJOpts --main-class "$entry" --property "scala.usejavacp=true" --property "scala.use_legacy_launcher=true"""" +: newOptions)*)._2
170170

171171
/** Get coursier script */
172172
@BeforeClass def setup(): Unit =

0 commit comments

Comments
 (0)