-
-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set the Scala version or the Ammonite version #1093
Comments
ammonite-runner allows things along the lines of what you're proposing, by acccepting Ammonite and / or Scala versions in comments before any scala code, like // Ammonite 2.1.4, scala 2.12.11 For now, it can be run scripts with
(Note that this will works when its It's initially been written to fetch Ammonite from metals. I'd be ok moving it to the main repo if it makes sense for everyone. And / or tweak the way it reads the Ammonite and scala version from scripts. |
In the mean time, coursier allows to run specific Ammonite / scala combinations, like
or
(Both full and binary version are accepted as scala versions, and the Ammonite version is optional.) |
I'm glad there's a ticket on this because it's actually one of the things that has held me back from adopting Ammonite for my own scripting. (And yes, I should have opened an issue myself, long ago.) I'll try to find time to give ammonite-runner a spin, looks cool |
One can use the workaround above in bash script like so:
|
I think it would be better to find a solution that does not require a custom way of running the application. Basically, if I distribute an ammonite script, I want users to be able to run it by just running |
Are there any plans to implement this feature? Or an idea on how to go about it? I would think that it is quite critical for the proper use in production environment, I could work on it. |
Hello @ptrdom, would using scala-cli instead of ammonite work for you? Scala-cli does support this feature. |
Hey @julienrf, I had not heard about scala-cli before and after a quick glance it does seem to have the features I need, many thanks! |
The fact that Scala and Ammonite evolve can make it impossible to run old scripts with a new version of Ammonite.
This problem is solved by sbt by having a
build.properties
file that sets the sbt version, and then ascalaVersion
setting that sets the Scala version. This allows me to keep untouched very old programs and still be able to run them with the latest sbt launcher.I would like to see a similar mechanism here. Maybe with magical imports?
The text was updated successfully, but these errors were encountered: