Open benwbooth opened 2 years ago
Hi @benwbooth,
What do you mean by adding a script search path feature? If I understand correctly, Scala CLI should support the new environment variable SCALAPATH
, which contains a list of directories where scala-cli
should search files defined as input.
For example, when I have set SCALAPATH='/tmp/scripts/Util.scala
. Should the following example work?
$ cat /tmp/scripts/Util.scala
object Util {
val msg = "Hello World"
}
$ pwd
/User/lwronski/
$ cat Hello.scala
/> using path "Util.scala"
object Hello extends App {
println(Util.msg)
}
$ scala-cli Hello.scala
Hello World
@lwronski Where was the discussion and the requirements for this SCALAPATH feature captured?
I'm not seeing results in the usual places.
This seems like a large semantic change to how scala works.
I believe a reasonable workaround would be to use softlinks.
@mpkocher For now, scala-cli doesn't support SCALAPATH
. I agree, that it huge semantics change to scala-cli so it requires more discussion.
Now, scala-cli users can use file
directive to define inputs, something like this:
//> using file "Utils.scala" "dir/scripts"
more info can you find here.
It would be helpful if a new feature was added to allow a script search path, such as is used in other scripting languages such as perl and python. The user should be able to set the script search path using a command-line argument to scala-cli, a
using
directive e.g.//> using path "../../modules"
, a setting in theproject.settings.scala
file or a colon-delimited environment variable, e.g.SCALAPATH
or some other name. This would give the user more flexibility when writing//> using file
directives, so that instead of using only the running script's directory as the base when resolving relative script paths, it would instead search the script path. The running script's parent directory could be implicitly added to the search path by default.