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

Version 4.0 of `sbt-debug-adapter` breaks `sbt`

samuelchassot opened this issue · comments

Describe the bug

When opening a project with metals, the plugin sbt-adapter is added to the metals.sbt file (addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % "4.0.2")). When the version 4.x is used, sbt crashes when loading the project with the following error message:

[error] Runtime references to undefined settings: 
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "smtParser") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/scala-smtlib.git#51a44878858b427f1a4e5a5eb01d8f796898d812"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "parser") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/cafebabe.git#616e639b34379e12b8ac202849de3ebbbd0848bc"), "cafebabe") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/inox.git#3b02dcf4308f9e8d74ea82304bd651be8e93517f"), "root") / Test / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/inox.git#3b02dcf4308f9e8d74ea82304bd651be8e93517f"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error]  
[error] 	at sbt.internal.util.Init.Uninitialized(Settings.scala:419)
[error] 	at sbt.internal.util.Init.Uninitialized$(Settings.scala:406)
[error] 	at sbt.Def$.Uninitialized(Def.scala:24)
[error] 	at sbt.internal.util.Init.makeWithCompiledMap(Settings.scala:225)
[error] 	at sbt.internal.util.Init.makeWithCompiledMap$(Settings.scala:212)
[error] 	at sbt.Def$.makeWithCompiledMap(Def.scala:24)
[error] 	at sbt.internal.Load$.$anonfun$apply$5(Load.scala:261)
[error] 	at sbt.internal.Load$.timed(Load.scala:1406)
[error] 	at sbt.internal.Load$.apply(Load.scala:253)
[error] 	at sbt.internal.Load$.defaultLoad(Load.scala:56)
[error] 	at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:961)
[error] 	at sbt.BuiltinCommands$.doLoadProject(Main.scala:961)
[error] 	at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:914)
[error] 	at sbt.Command$.$anonfun$applyEffect$4(Command.scala:150)
[error] 	at sbt.Command$.$anonfun$applyEffect$2(Command.scala:145)
[error] 	at sbt.Command$.process(Command.scala:189)
[error] 	at sbt.MainLoop$.$anonfun$processCommand$5(MainLoop.scala:245)
[error] 	at scala.Option.getOrElse(Option.scala:189)
[error] 	at sbt.MainLoop$.process$1(MainLoop.scala:245)
[error] 	at sbt.MainLoop$.processCommand(MainLoop.scala:278)
[error] 	at sbt.MainLoop$.$anonfun$next$5(MainLoop.scala:163)
[error] 	at sbt.State$StateOpsImpl$.runCmd$1(State.scala:289)
[error] 	at sbt.State$StateOpsImpl$.process$extension(State.scala:325)
[error] 	at sbt.MainLoop$.$anonfun$next$4(MainLoop.scala:163)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.MainLoop$.next(MainLoop.scala:163)
[error] 	at sbt.MainLoop$.run(MainLoop.scala:144)
[error] 	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:119)
[error] 	at sbt.io.Using.apply(Using.scala:27)
[error] 	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:112)
[error] 	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:66)
[error] 	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:51)
[error] 	at sbt.MainLoop$.runLogged(MainLoop.scala:42)
[error] 	at sbt.StandardMain$.runManaged(Main.scala:223)
[error] 	at sbt.xMain$.$anonfun$run$11(Main.scala:133)
[error] 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error] 	at scala.Console$.withIn(Console.scala:230)
[error] 	at sbt.internal.util.Terminal$.withIn(Terminal.scala:577)
[error] 	at sbt.internal.util.Terminal$.$anonfun$withStreams$1(Terminal.scala:358)
[error] 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error] 	at scala.Console$.withOut(Console.scala:167)
[error] 	at sbt.internal.util.Terminal$.$anonfun$withOut$2(Terminal.scala:567)
[error] 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error] 	at scala.Console$.withErr(Console.scala:196)
[error] 	at sbt.internal.util.Terminal$.withOut(Terminal.scala:567)
[error] 	at sbt.internal.util.Terminal$.withStreams(Terminal.scala:358)
[error] 	at sbt.xMain$.withStreams$1(Main.scala:87)
[error] 	at sbt.xMain$.run(Main.scala:121)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] 	at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:57)
[error] 	at sbt.xMain.run(Main.scala:46)
[error] 	at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
[error] 	at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
[error] 	at xsbt.boot.Launch$.run(Launch.scala:149)
[error] 	at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
[error] 	at xsbt.boot.Launch$.launch(Launch.scala:159)
[error] 	at xsbt.boot.Launch$.apply(Launch.scala:44)
[error] 	at xsbt.boot.Launch$.apply(Launch.scala:21)
[error] 	at xsbt.boot.Boot$.runImpl(Boot.scala:78)
[error] 	at xsbt.boot.Boot$.run(Boot.scala:73)
[error] 	at xsbt.boot.Boot$.main(Boot.scala:21)
[error] 	at xsbt.boot.Boot.main(Boot.scala)
[error] Runtime references to undefined settings: 
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "smtParser") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/scala-smtlib.git#51a44878858b427f1a4e5a5eb01d8f796898d812"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "parser") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/uuverifiers/princess.git#93cbff11d7b02903e532c7b64207bc12f19b79c7"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/cafebabe.git#616e639b34379e12b8ac202849de3ebbbd0848bc"), "cafebabe") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/inox.git#3b02dcf4308f9e8d74ea82304bd651be8e93517f"), "root") / Test / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error] 
[error]   ProjectRef(uri("https://github.com/epfl-lara/inox.git#3b02dcf4308f9e8d74ea82304bd651be8e93517f"), "root") / Compile / debugAdapterClassUpdates from stainless-dotty / Test / startMainClassDebugSession ((ch.epfl.scala.debugadapter.sbtplugin.DebugAdapterPlugin.runSettings) DebugAdapterPlugin.scala:107)
[error]  
[error] Use 'last' for the full log.

The problem disappears when using the version 3.x of the plugin.

Expected behavior

The project should be loaded by sbt without crashing even when using metals.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.31.0

Extra context or search terms

This can be reproduced with this project: https://github.com/epfl-lara/stainless

Thanks for reporting! Does it work on the latest nightly, it uses newer version 4.0.4. @adpi2 any idea what might going on, or is it something fixed in later release?

any idea what might going on, or is it something fixed in later release?

I need to investigate this further.

Thanks for the reply!
I'll test with the nightly, I'll keep you posted!

I'll test with the nightly, I'll keep you posted!

I think I know what's wrong and it should not work in the nightly. stainless uses ghProject and those projects don't have the DebugAdapterPlugin enabled, hence the missing settings. I can fix this bug by filtering out the projects with missing settings.

that'd be great! :)