Describe the bug
Metals: Import Build stopped working. It has been working fine for months, on this project in fact. I added a dependency and was unable to re-import.
To Reproduce
.scala file and then do Metals: Import BuildBehold the log:
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Using JAVA options set in JAVA_OPTS
logging to file /Users/rnorris/Scala/skunk/.metals/metals.log
time: initialize in 0.79s
running 'sbt metalsEnable bloopInstall'
[info] Loading settings for project global-plugins from metals.sbt ...
[info] Loading global plugins from /Users/rnorris/.sbt/1.0/plugins
[info] Loading settings for project skunk-build from plugins.sbt ...
[info] Loading project definition from /Users/rnorris/Scala/skunk/project
[success] Generated .bloop/skunk-build.json
[success] Total time: 1 s, completed Apr 21, 2019 8:55:18 PM
[info] Loading settings for project skunk from build.sbt,version.sbt ...
[info] Set current project to skunk (in build file:/Users/rnorris/Scala/skunk/)
[error] Not a valid command: metalsEnable
[error] Not a valid project ID: metalsEnable
[error] Expected ':'
[error] Not a valid key: metalsEnable
[error] metalsEnable
[error] ^
sbt exit: 1
time: ran 'sbt bloopInstall' in 13s
sbt command failed: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/bin/java -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -jar /var/folders/kt/st5ktl_x5q735j6bk1tc9t4m00038z/T/metals1125816136586707218/sbt-launch.jar metalsEnable bloopInstall
Installation:
Additional context
My /Users/rnorris/.sbt/1.0/plugins/metals.sbt looks correct, I think.
// DO NOT EDIT! This file is auto-generated.
// By default, this file does not do anything.
// If the environment variable METALS_ENABLED has the value 'true',
// then this file enables sbt-metals and sbt-bloop.
libraryDependencies := {
import Defaults.sbtPluginExtra
val oldDependencies = libraryDependencies.value
if (System.getenv("METALS_ENABLED") == "true") {
val bloopModule = "ch.epfl.scala" % "sbt-bloop" % "1.2.5"
val metalsModule = "org.scalameta" % "sbt-metals" % "0.5.0"
val sbtVersion = Keys.sbtBinaryVersion.in(TaskKey[Unit]("pluginCrossBuild")).value
val scalaVersion = Keys.scalaBinaryVersion.in(update).value
val bloopPlugin = sbtPluginExtra(bloopModule, sbtVersion, scalaVersion)
val metalsPlugin = sbtPluginExtra(metalsModule, sbtVersion, scalaVersion)
List(bloopPlugin, metalsPlugin) ++ oldDependencies.filterNot { dep =>
(dep.organization == "ch.epfl.scala" && dep.name == "sbt-bloop") ||
(dep.organization == "org.scalameta" && dep.name == "sbt-metals")
}
} else {
oldDependencies
}
}
Thank you for reporting! Do you have sbt-coursier installed? What happens if you upgrade to sbt-coursier 1.1.0-M14-1? This looks related to https://github.com/scalameta/metals/issues/567
No coursier but after some discussion with @olafurpg we tried
rm -rf project/target
rm -rf ~/.sbt/1.0/plugins/target/
and that fixed it! So if anyone else is in this situation it's worth a try.
Another related issue https://github.com/scalameta/metals/issues/685#issuecomment-485017080
Most helpful comment
No coursier but after some discussion with @olafurpg we tried
and that fixed it! So if anyone else is in this situation it's worth a try.