scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

If a scala file has a colon anywhere in the path (including parent directories) the scala-cli can't run and does not give helpful warnings

Open oliverlevay opened this issue 3 years ago • 0 comments

Version(s) Probably all but tested on 0.1.15

Describe the bug scala-cli cannot run scala code that is in a path that contains a : anywhere in the path. Compiling is possible but running is not. There also is not a helpful warning to help the user, the error is just:

Exception in thread "main" java.lang.ClassNotFoundException: main
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at scala.cli.runner.Runner$.main(Runner.scala:13)
        at scala.cli.runner.Runner.main(Runner.scala)

in my case the code was:

@main def main = println("test")

, but the bug is reproducible with any code

To Reproduce

  1. Create a directory with : in the name, for example scala:cli
  2. Create a scala file in the newly created directory and put in some code, any code, that you know would run perfectly otherwise.
  3. Type scala-cli run . or scala-cli run FileName.scala.

Note: This bug is irrelevant on Windows, since you can't create directories with : in the name on Windows. However it is tested on both Mac and Ubuntu and the bug exists on both.

Expected behaviour The code should run as normal or at least give a meaningful warning.

oliverlevay avatar Sep 30 '22 22:09 oliverlevay