Open EskoJTH opened 2 years ago
It's defined in your build.sbt
. Can you change this version in vscode? If you can then there will be a similar way to do it in emacs.
I do not have build.sbt I'm running these as stand alone scripts. Previously everything worked pretty much perfectly in emacs. I haven't used vscode for a long time. There has been some ammonite support officially in metals for a couple of years though. https://scalameta.org/metals/blog/2020/07/01/lithium/ .
In vscode it seems to default to correct version of the compiler for some reason. I didn't manage to change the version yet though. metals seems to say something like this to me: 2022.09.06 13:38:02 INFO no build target found for /home/esko/harjo/ammo/muodoton4typeClasses.worksheet.sc. Using presentation compiler with project's scala-library version: 2.12.13 Now I wonder what is "presentation compiler" and where is its version defined.
Ammonite does not seem to have a way to define this inside a file and my ammonite is on the correct scala version.
You can specify the Ammonite version as a comment like // scala 2.13.8
before your code, see here: https://scalameta.org/metals/docs/troubleshooting/faq/#how-do-i-use-scala-2xx-for-my-script.
FYI you can also check more easily which scala versions are being used for partcular scripts using lsp-metals-doctor-run
.
Thanks a lot! This seems to have fixed everything. Somehow I did not find that line of documentation.
Cool glad I could help :slightly_smiling_face:
What is the preferred way of changing scala version for independent .worksheet.sc files? I updated everything lsp related and now I seem to be stuck on scala version 3 while I need scala 2.13. Ammonite does not seem to have a way to define this inside a file and my ammonite is on the correct scala version. I wasn't quite sure what is the system responsible of the version so sorry if this is the wrong place to ask.