0

I am trying to set up emacs as scala editor. To that end i am trying to install metals for corresponding modes to work.

However, for some reason or another, metals either failed to install from emacs, or when installed with Coursier, were not responsive from emacs.

So, to explore all the options i decided to use metals source code (from Github? but i have run into the issue of being unable to properly utilize them.

What can i do to make metals available to emacs from the sources?

Currently, i have tried building them with

sbt publishLocal

and then trying to run the jar that was generated, with predictable result:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/Seq at scala.meta.metals.Main.main(Main.scala) Caused by: java.lang.ClassNotFoundException: scala.collection.Seq 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) ... 1 more

Process metals stderr finished Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/Seq at scala.meta.metals.Main.main(Main.scala) Caused by: java.lang.ClassNotFoundException: scala.collection.Seq 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) ... 1 more

Process metals stderr finished

In my system i have installed with sbt, as suggested by the instructions on scala website.

How should i setup the system so that metals could be launched and used?

Srv19
  • 3,458
  • 6
  • 44
  • 75

1 Answers1

1

You shouldn't need to compile Metals from sources just to use it from Emacs. Check the official documentation: Emacs | Metals, especially the requirements and installation sections. It mentions

Next you have to install metals server. Emacs can do it for you when lsp-mode is enabled in a scala buffer or via lsp-install-server command. Also you can do it manually executing coursier install metals and configuring $PATH variable properly.

If you have problems with the installation, try asking on Scalameta Discord for help. There is a dedicated #emacs-users channel as well.


That said, if you still want to use a locally published Metals artifact for whatever other reason (e.g. contributing to the Metals code and testing changes locally), you should be able to do that. The contributing documentation describes how to work with the codebase and test your local Metals version.

In short, after you ran sbt publishLocal, you need to update the server version setting in your editor and run the Metals: Restart server command. It should pick up the locally published version.

laughedelic
  • 6,230
  • 1
  • 32
  • 41
  • I did try lsp-install-server and installing with coursier (2 times, even, second times as jar launcher). No success, sadly. I do not now if the issue was with metals (as when launched from command line it did not give any output) or with emacs (as it just displayed "starting" in the status bard longer then i was willing to wait). – Srv19 Jan 29 '22 at 15:20
  • I recommend going to Discord for a more interactive debug help – laughedelic Feb 01 '22 at 18:38