Metals: sbt-scalafix breaks Metals Import when semanticdb versions mismatch

Created on 29 Jun 2019  Â·  1Comment  Â·  Source: scalameta/metals

Describe the bug
The VS code task "build import" is very sensitive to semanticdb-versions. If the extension sbt-scalafix is enabled on a project, and sbt-scalafix's required version of semanticdb doesn't exactly match whatever version of semanticdb metals add to the bloop configs, the import will fail.

To Reproduce
Steps to reproduce the behavior:

  1. Add sbt-scalafix to project/plugins.sbt: addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.5")
  2. Enable scalafixSemanticdb on project: addCompilerPlugin(scalafixSemanticdb)
  3. Run Metals Import (using version 1.5.1 of the VS Code extension in my case)
  4. Watch import logs

Expected behavior
Importing a project where scalafix is used should work.

Since metals adds its desired version of semanticdb to all projects it imports while generating bloop configs, this may well clash with the version required by scalafixSemanticdb. I'm not sure how to work around this; perhaps metals could be more sensitive in detecting if there are other versions of semanticdb already installed and use those if they are compatible.

Error log

[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:
[warn]  * org.scalameta:semanticdb-scalac_2.12.8:(4.1.9, 4.2.0)
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
…
[error] Missing required plugin: semanticdb
[error] bad option: -P:semanticdb:synthetics:on
[error] bad option: -P:semanticdb:failures:warning
[error] bad option: -P:semanticdb:sourceroot:/Users/martin/dev/future-memories/sortapp-es
[error] four errors found

Installation:

  • Operating system: macOS
  • Editor: Visual Studio Code
  • Metals version: v0.5.1

Additional context

Search terms
semanticdb metals build import

bug

Most helpful comment

Thanks for reporting! We are actually working on simplifying the way we add semanticdb plugin and that should fix the issue. Will let you know when we get it working.

>All comments

Thanks for reporting! We are actually working on simplifying the way we add semanticdb plugin and that should fix the issue. Will let you know when we get it working.

Was this page helpful?
0 / 5 - 0 ratings