Make sure you have coursier installed
chmod +x test.scala
./test.scala
First time it will download scala-compiler (and depending on your config maybe GraalVM) then cache a bootstrap runner. Next time it will run much faster using the cached runner (depending on you config can be native program!).