Closed joan38 closed 13 hours ago
Extra context from discord: @joan38 said:
So we actually use Scala CLI. We just wrote some code that federates multiple Scala CLI module. In a nuteshell we wrote a BSP server that only forwards the requests to the Scala CLI of each module It works all fine when we do that but as soon as we ask Scala CLI to move the .scala-build folder with --workspace to a different folder (because we want them grouped in 1 folder that we can delete easily) then it starts to create all those .scala.semanticdb files. I'm not 100% sure it's Metals or Scala CLI but you seem to know what I'm talking about?
Scala CLI treats --workspace
as your project root. This means that for SemanticDB relative paths will also be calculated using --workspace
as the root. Since in your case the relative path from --workspace
to source file requires going up this will fail. Scala 3 compiler as a fallback in such situations creates .scala.semanticdb
next to the source.
Scala 3 fix: add --semanticdb-sourceroot <project-root>
, then <project-root>
will be used as root for semanticDB.
Docs: https://scala-cli.virtuslab.org/docs/reference/scala-command/cli-options#--semantic-db-target-root Connected PRs: https://github.com/VirtusLab/scala-cli/pull/2784 https://github.com/VirtusLab/scala-cli/pull/2784
Note: This will also work for Scala 2 .scala
files but fail for Scala 2 scripts..
Thanks @kasiaMarek for the explanation.
Adding --semanticdb-sourceroot
worked!
Should we close this?
Yes, closing this.
Describe the bug
It sounds like https://github.com/scalameta/metals/commit/afc1c67b97dfff80b3587b982e77ef148cab639e did not really fix the issue.
Expected behavior
No
.semanticdb
files next to every single.scala
source filesOperating system
macOS
Editor/Extension
VS Code
Version of Metals
1.3.2+25-fe9a85a4-SNAPSHOT
Extra context or search terms
No response