Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SemanticDB options on an sbt dotty project are wrong #2189

Closed
adpi2 opened this issue Nov 3, 2020 · 4 comments · Fixed by #2191
Closed

SemanticDB options on an sbt dotty project are wrong #2189

adpi2 opened this issue Nov 3, 2020 · 4 comments · Fixed by #2191
Labels
BSP Generic BSP related tickets bug Something that is making a piece of functionality unusable sbt server Relates to sbt BSP server support sbt Generic relation to sbt
Milestone

Comments

@adpi2
Copy link
Member

adpi2 commented Nov 3, 2020

Describe the bug

The sbt-metals plugin generates wrong SemanticDB options on the Test configuration of a Dotty project.

To Reproduce

Steps to reproduce the behavior:

  1. Create an sbt dotty project
// project/plugin.sbt
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.4")
addSbtPlugin("org.scalameta" % "sbt-metals" % "0.9.5-SNAPSHOT")
// build.sbt
scalaVersion := "0.27.0-RC1"
  1. Run show Test / scalacOptions in an sbt shell
sbt:example> show Test / scalacOptions
[info] * -Ysemanticdb
[info] * -semanticdb-target
[info] * /example/target/scala-0.27/meta
[info] * /example/target/scala-0.27/test-meta
  1. Run Test / compile in an sbt shell
sbt:example> Test / compile
[info] compiling 4 Scala sources to /example/target/scala-0.27/test-classes ...
[error] expected file, received directory '/example/target/scala-0.27/test-meta'
[error] one error found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 0 s, completed Nov 3, 2020, 9:19:14 PM

Expected behavior

The scalacOptions of the Test configuration should be:

sbt:example> show Test / scalacOptions
[info] * -Ysemanticdb
[info] * -semanticdb-target
[info] * /example/target/scala-0.27/test-meta

Installation:

  • Operating system: Linux
  • Metals version: v0.9.5-SNAPSHOT

Search terms

SemanticDB, compiler options, dotty, scala 3, sbt-metals

@adpi2
Copy link
Member Author

adpi2 commented Nov 3, 2020

This lines of code in sbt/sbt could help to fix this issue:

https://github.com/sbt/sbt/blob/c00196abf0c0b60d301e9516b8513b498359f987/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala#L68-L76

As you can see, the target root coming from the Compile configuration is removed before we add the Test target root.

@adpi2
Copy link
Member Author

adpi2 commented Nov 3, 2020

Maybe it is even easier to just do semanticdbEnabled := true in sbt-metals. It should add the required -Ysemanticdb and the correct -semanticdb-target options.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 4, 2020

Thanks for reporting! Good catch! I can confirm it's an issue. Should be easy to fix in the plugin.

@tgodzik tgodzik added BSP Generic BSP related tickets bug Something that is making a piece of functionality unusable sbt Generic relation to sbt sbt server Relates to sbt BSP server support labels Nov 4, 2020
@tgodzik tgodzik added this to the Metals v0.9.5 milestone Nov 4, 2020
@ckipp01
Copy link
Member

ckipp01 commented Nov 4, 2020

Thanks for the report @adpi2! I should have it fixed in #2139

Maybe it is even easier to just do semanticdbEnabled := true in sbt-metals. It should add the required -Ysemanticdb and the correct -semanticdb-target options.

That was originally brought up in #2049, but there seemed to be concern about ensuring that the user has a supported Scala version. So we don't want to just check check the sbt version and enable it based off that which could cause issues from my understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP Generic BSP related tickets bug Something that is making a piece of functionality unusable sbt server Relates to sbt BSP server support sbt Generic relation to sbt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants