sbt / sbt

sbt, the interactive build tool
https://scala-sbt.org
Apache License 2.0
4.81k stars 937 forks source link

Using `-Xfatal-warnings` in `project/plugins.sbt` and Metals together may cause loading failure #7348

Closed danielleontiev closed 1 year ago

danielleontiev commented 1 year ago

Originally reported here: https://github.com/scalameta/metals/issues/5475

Prerequisites:

1) Having code that produces some warning under project/src/main/scala 2) Having scalacOptions += "-Xfatal-warnings" in project/plugins.sbt

Note, that at that poing project loads with no issues. Example:

.
├── build.sbt
└── project
   ├── build.properties
   ├── plugins.sbt
   └── src
      └── main
         └── scala
            └── Test.scala

project/build.properties:

sbt.version=1.9.2

project/plugins.sbt:

scalacOptions += "-Xfatal-warnings"

project/src/main/scala/Test.scala:

object Test {
  // trigger "a pure expression does nothing in statement position" warning here
  val a: Unit = ""
}

If launch sbt in the project directory everything loads successfully

`sbt` output ``` [info] welcome to sbt 1.9.2 (Eclipse Adoptium Java 17.0.5) [info] loading global plugins from /Users/daniilleontiev/.sbt/1.0/plugins [info] loading settings for project metals-load-fail-build-build from metals.sbt ... [info] loading project definition from /Users/daniilleontiev/Desktop/metals-load-fail/project/project [info] loading settings for project metals-load-fail-build from plugins.sbt ... [info] loading project definition from /Users/daniilleontiev/Desktop/metals-load-fail/project [info] compiling 1 Scala source to /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes ... [info] loading settings for project metals-load-fail from build.sbt ... [info] set current project to hello (in build file:/Users/daniilleontiev/Desktop/metals-load-fail/) [info] sbt server started at local:///Users/daniilleontiev/.sbt/1.0/server/1e2098356feb51d1884e/sock [info] started sbt server sbt:hello> ```

Note, that despite having code that should produce warning in project/src/main/scala/Test.scala we do not see it in sbt output.

Adding metals

To trigger the issue Metals sbt plugin should be added to project/project/metals.sbt:

addSbtPlugin("org.scalameta" % "sbt-metals" % "1.0.0")

Now running sbt will end up in load failure.

`sbt` output ``` [info] welcome to sbt 1.9.2 (Eclipse Adoptium Java 17.0.5) [info] loading global plugins from /Users/daniilleontiev/.sbt/1.0/plugins [info] loading settings for project metals-load-fail-build-build from metals.sbt ... [info] loading project definition from /Users/daniilleontiev/Desktop/metals-load-fail/project/project [info] loading settings for project metals-load-fail-build from plugins.sbt ... [info] loading project definition from /Users/daniilleontiev/Desktop/metals-load-fail/project [info] compiling 1 Scala source to /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes ... [error] No warnings can be incurred under -Xfatal-warnings. [error] one error found [error] (Compile / compileIncremental) Compilation failed [warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r) ```

The hard part is that I've not found the way to locate the source of the No warnings can be incurred under -Xfatal-warnings. error. Running sbt --debug shows the following

`sbt` output ``` [addSbt] arg = '-debug' [sbt_options] declare -a sbt_options='()' [process_args] java_version = '17' [addMemory] arg = '1024' [addJava] arg = '-Xms1024m' [addJava] arg = '-Xmx1024m' [addJava] arg = '-Xss4M' [addJava] arg = '-XX:ReservedCodeCacheSize=128m' [addJava] arg = '-Dsbt.script=/Users/daniilleontiev/Library/Caches/Coursier/arc/https/github.com/sbt/sbt/releases/download/v1.9.0/sbt-1.9.0.zip/sbt/bin/sbt' [copyRt] java9_rt = '/Users/daniilleontiev/.sbt/1.0/java9-rt-ext-eclipse_adoptium_17_0_5/rt.jar' [addJava] arg = '-Dscala.ext.dirs=/Users/daniilleontiev/.sbt/1.0/java9-rt-ext-eclipse_adoptium_17_0_5' # Executing command line: java -Dfile.encoding=UTF-8 -Xms1024m -Xmx1024m -Xss4M -XX:ReservedCodeCacheSize=128m -Dsbt.script=/Users/daniilleontiev/Library/Caches/Coursier/arc/https/github.com/sbt/sbt/releases/download/v1.9.0/sbt-1.9.0.zip/sbt/bin/sbt -Dscala.ext.dirs=/Users/daniilleontiev/.sbt/1.0/java9-rt-ext-eclipse_adoptium_17_0_5 -jar /Users/daniilleontiev/Library/Caches/Coursier/arc/https/github.com/sbt/sbt/releases/download/v1.9.0/sbt-1.9.0.zip/sbt/bin/sbt-launch.jar -debug [debug] not up to date. inChanged = true, force = false [debug] Updating ProjectRef(uri("file:/Users/daniilleontiev/.sbt/1.0/plugins/"), "global-plugins")... [debug] Done updating ProjectRef(uri("file:/Users/daniilleontiev/.sbt/1.0/plugins/"), "global-plugins") [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/.sbt/1.0/plugins/target/scala-2.12/sbt-1.0/classes.bak [debug] About to delete class files: [debug] We backup class files: [debug] [zinc] IncrementalCompile ----------- [debug] IncrementalCompile.incrementalCompile [debug] previous = Stamps for: 0 products, 0 sources, 0 libraries [debug] current source = Set() [debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set()) [debug] Full compilation, no sources in previous analysis. [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/.sbt/1.0/plugins/target/scala-2.12/sbt-1.0/classes.bak [debug] Removing the temporary directory used for backing up class files: /Users/daniilleontiev/.sbt/1.0/plugins/target/scala-2.12/sbt-1.0/classes.bak [debug] Copy resource mappings: [debug] [debug] Other repositories: [debug] Default repositories: [debug] Using inline dependencies specified in Scala. [debug] not up to date. inChanged = true, force = false [debug] Updating ProjectRef(uri("file:/Users/daniilleontiev/Desktop/metals-load-fail/project/project/"), "metals-load-fail-build-build")... [debug] Done updating ProjectRef(uri("file:/Users/daniilleontiev/Desktop/metals-load-fail/project/project/"), "metals-load-fail-build-build") [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/Desktop/metals-load-fail/project/project/target/scala-2.12/sbt-1.0/classes.bak [debug] About to delete class files: [debug] We backup class files: [debug] [zinc] IncrementalCompile ----------- [debug] IncrementalCompile.incrementalCompile [debug] previous = Stamps for: 0 products, 0 sources, 0 libraries [debug] current source = Set() [debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set()) [debug] Full compilation, no sources in previous analysis. [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/Desktop/metals-load-fail/project/project/target/scala-2.12/sbt-1.0/classes.bak [debug] Removing the temporary directory used for backing up class files: /Users/daniilleontiev/Desktop/metals-load-fail/project/project/target/scala-2.12/sbt-1.0/classes.bak [debug] Copy resource mappings: [debug] [debug] not up to date. inChanged = true, force = false [debug] Updating ProjectRef(uri("file:/Users/daniilleontiev/Desktop/metals-load-fail/project/"), "metals-load-fail-build")... [debug] Done updating ProjectRef(uri("file:/Users/daniilleontiev/Desktop/metals-load-fail/project/"), "metals-load-fail-build") [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes.bak [debug] About to delete class files: [debug] We backup class files: [debug] [zinc] IncrementalCompile ----------- [debug] IncrementalCompile.incrementalCompile [debug] previous = Stamps for: 0 products, 0 sources, 0 libraries [debug] current source = Set(${BASE}/project/src/main/scala/Test.scala) [debug] > initialChanges = InitialChanges(Changes(added = Set(${BASE}/project/src/main/scala/Test.scala), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set()) [debug] Full compilation, no sources in previous analysis. [debug] all 1 sources are invalidated [debug] Created transactional ClassFileManager with tempDir = /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes.bak [debug] Initial set of included nodes: [debug] Recompiling all sources: number of invalidated sources > 50.0 percent of all sources [debug] About to delete class files: [debug] We backup class files: [debug] compilation cycle 1 [info] compiling 1 Scala source to /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes ... [debug] Getting org.scala-sbt:compiler-bridge_2.12:1.9.2:compile for Scala 2.12.18 [debug] [zinc] Running cached compiler 1ce65d26 for Scala compiler version 2.12.18 [debug] [zinc] The Scala compiler is invoked with: [debug] -deprecation [debug] -Wconf:cat=unused-nowarn:s [debug] -Xfatal-warnings [debug] -Wconf:cat=unused-nowarn:s [debug] -Xsource:3 [debug] -Xplugin:/Users/daniilleontiev/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.12.18/4.8.3/semanticdb-scalac_2.12.18-4.8.3.jar [debug] -Yrangepos [debug] -P:semanticdb:synthetics:on [debug] -P:semanticdb:failures:warning [debug] -P:semanticdb:sourceroot:/Users/daniilleontiev/Desktop/metals-load-fail/project [debug] -P:semanticdb:targetroot:/Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/meta [debug] -bootclasspath [debug] /Users/daniilleontiev/.sbt/boot/scala-2.12.18/lib/scala-library.jar [debug] -classpath [debug] /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes:/Users/daniilleontiev/.sbt/1.0/plugins/target/scala-2.12/sbt-1.0/classes:/Users/daniilleontiev/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/sourcegraph/semanticdb-javac/0.8.24/semanticdb-javac-0.8.24.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/lib/scala-compiler.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/lib/scala-reflect.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/lib/scala-xml_2.12-2.1.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/compiler-bridge_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jna-5.13.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-tracking_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-core_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/slf4j-api-1.7.36.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/shaded-jawn-parser_2.12-0.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/completion_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-apiinfo_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-reader-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/log4j-api-2.17.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/test-agent-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-lm-integration_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/sbinary_2.12-0.5.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/error_prone_annotations-2.4.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/gigahorse-core_2.12-0.7.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/config-1.4.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/test-interface-1.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-compile-core_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-terminal-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/testing_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/sjson-new-core_2.12-0.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/gigahorse-apache-http_2.12-0.7.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-classfile_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/librarymanagement-ivy_2.12-1.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/checker-qual-3.4.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/task-system_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/caffeine-2.8.5.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-cache_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/log4j-core-2.17.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/main_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/log4j-slf4j-impl-2.17.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-position_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/launcher-interface-1.4.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-2.14.7-sbt-a1b0ffbb8f64bb820f4f84a0c07a0c0964507493.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-compile_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-terminal-jna-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/ssl-config-core_2.12-0.6.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-relation_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-interface-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/file-tree-views-2.1.10.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/librarymanagement-core_2.12-1.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/sbt-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/logic_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-terminal-jansi-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-persist-core-assembly-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scala-parser-combinators_2.12-1.1.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/collections_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/tasks_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/reactive-streams-1.0.3.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scala-collection-compat_2.12-2.9.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jansi-2.1.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scripted-plugin_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scala-reflect-2.12.18.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jna-platform-5.13.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/disruptor-3.4.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/actions_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-builtins-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/command_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/sjson-new-murmurhash_2.12-0.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/template-resolver-0.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/main-settings_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/core-macros_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-control_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scala-compiler-2.12.18.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/protocol_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/sjson-new-scalajson_2.12-0.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jsch-0.1.54.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/scala-xml_2.12-2.1.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/jline-style-3.19.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/util-logging_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/run_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/lm-coursier-shaded_2.12-2.1.0.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/ivy-2.3.0-sbt-a8f9eb5bf09d0539ea3658a2c2d4e09755b5133e.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zero-allocation-hashing-0.10.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/compiler-interface-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/ipcsocket-1.6.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/io_2.12-1.9.1.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-classpath_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/shaded-scalajson_2.12-1.0.0-M4.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/zinc-persist_2.12-1.9.2.jar:/Users/daniilleontiev/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.2/shaded-apache-httpasyncclient-0.7.0.jar [debug] a pure expression does nothing in statement position [error] No warnings can be incurred under -Xfatal-warnings. [error] one error found [debug] Compilation failed (CompilerInterface) [debug] Rolling back changes to class files. [debug] Removing generated classes: [debug] Restoring class files: [debug] Removing the temporary directory used for backing up class files: /Users/daniilleontiev/Desktop/metals-load-fail/project/target/scala-2.12/sbt-1.0/classes.bak [error] (Compile / compileIncremental) Compilation failed ```

Now we have some clue about what is going on near the end of output [debug] a pure expression does nothing in statement position but it does not point to the actual source file. Now I am in the situation where I have a real project that fails to load and I still cannot find the actual cause 😅 because there are a lot of stuff in project/src.

I also have added the minimal example described here to the repository https://github.com/danielleontiev/metals-load-fail

more

It may be related to https://github.com/sbt/sbt/issues/6433 but it's interesting that adding Metals sbt plugins makes -Xfatal-warnings to work in some way - failing compilation but without pointing to the source file that has error

eed3si9n commented 1 year ago

Let's merge the discussion on this to https://github.com/sbt/sbt/issues/6433