scalameta / metals

Scala language server with rich IDE features 🚀

Home Page:https://scalameta.org/metals/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metals starts multiple bsp servers when using sbt ProjectRef

mberndt123 opened this issue · comments

Describe the bug

In sbt, it is possible to add a dependency on a module in another build using dependsOn:

val foo = project.dependsOn(ProjectRef(file("../some-library"), "some-library-module"))

This is useful when modifying both a program and a library used by that program. In order to do this, I also add the ../some-library directory to my VS Code workspace by right-clicking in the explorer and selecting Add Folder to workspace .

Unfortunately, this leads to a situation where two separate sbt instances are started, one for the main program and one for the library, both of which feel that they're in charge of compiling the library. This leads to all sorts of issues, like frequent unnecessary compilation of the library codebase.

Expected behavior

No sbt bsp server should be started for the library, because the main program's sbt instance is in charge.

It's not obvious what should happen when I have two programs using a ProjectRef dependency on the same library; probably metals should just error out in that case and tell the user to only edit one such program at a time.

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

v1.2.2

Extra context or search terms

No response

Thanks for reporting, I think we should be able to easily check if the current connection doesn't already cover the newly added folder.