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

Compilation triggered repeatedly with no results using SBT BSP #6896

Open
antonsviridov-src opened this issue Oct 30, 2024 · 3 comments · May be fixed by #7006
Open

Compilation triggered repeatedly with no results using SBT BSP #6896

antonsviridov-src opened this issue Oct 30, 2024 · 3 comments · May be fixed by #7006
Assignees

Comments

@antonsviridov-src
Copy link

Describe the bug

  1. checkout this branch: https://github.com/disneystreaming/smithy4s/compare/series/0.18...keynmol:smithy4s:test-sbt-bsp-query?expand=1
  2. import the project using SBT BSP
  3. observe infinite recompilation

The branch is special because it enables a plugin that computes a single setting - bspEnabled: https://github.com/indoorvivants/sbt-bspquery/blob/main/mod/sbt-plugin/src/main/scala/SbtBspQueryPlugin.scala#L27, conditionally disabling some projects from the import

image

The BSP logs don't offer any insights

ceived notification 'build/taskStart'
Params: {
  "taskId": {
    "id": "1374",
    "parents": []
  },
  "eventTime": 1730290542519,
  "message": "Compiling core",
  "dataKind": "compile-task",
  "data": {
    "target": {
      "uri": "file:/Users/velvetbaldmime/projects/smithy4s/#core/Compile"
    }
  }
}


[Trace - 00:15:42 pm] Received notification 'build/taskFinish'
Params: {
  "taskId": {
    "id": "1374",
    "parents": []
  },
  "eventTime": 1730290542522,
  "message": "Compiled core",
  "status": 1,
  "dataKind": "compile-report",
  "data": {
    "target": {
      "uri": "file:/Users/velvetbaldmime/projects/smithy4s/#core/Compile"
    },
    "errors": 0,
    "warnings": 0,
    "time": 3,
    "noOp": true
  }
}
// again and again and again

Expected behavior

The project is imported normally and compiled only once

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.4.0

Extra context or search terms

sbt bsp compilation trigger

@kasiaMarek
Copy link
Contributor

The infinite compilation is caused by code generation. When code in core module is generated, Metals's file watcher emits create or modified events, which causes core to recompile, which triggers code generation task... Making an infinite loop.

@kasiaMarek kasiaMarek linked a pull request Dec 5, 2024 that will close this issue
@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

I wonder if this is not an issue with sbt. Does using ~core/compile has a similar issue?

Most of the generated sources are marked as such by sbt itself, any idea why this one isn't?

@kasiaMarek
Copy link
Contributor

I think it a mistake in the project setup. According to SBT docs:

A source generation task should generate sources in a subdirectory of sourceManaged and return a sequence of files generated.

For core:

sbt:root> show core/sourceManaged
[info] .../smithy4s/modules/core/target/jvm-2.13/src_managed

which is also correctly marked as generated in the build target:

.../smithy4s/modules/core/target/jvm-2.13/src_managed/main/* (generated)

But file

.../smithy4s/modules/core/src/generated/kinds/polyFunctions.scala

is also a generated file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

3 participants