I have a typical build.sbt where the content is merely a mult-modules project.
scalaVersion := "3.7.1"
lazy val server = (project in file("server"))
.settings(
scalaVersion := "3.7.1",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-ember-server" % "0.23.30",
"org.endpoints4s" %% "http4s-server" % "11.0.1",
"org.endpoints4s" %% "algebra" % "1.12.1",
"org.endpoints4s" %% "json-schema-generic" % "1.12.1",
"org.slf4j" % "slf4j-api" % "2.0.17",
"org.slf4j" % "slf4j-simple" % "2.0.17"
),
// Compile /run / fork := true <-- set fork to true as suggested by sbt after the warning is thrown
)
lazy val root = (project in file("."))
.aggregate(server)
When executing sbt server/run, it throws an expected warning
[info] running server.Main
[WARNING] IOApp `main` is running on a thread other than the main thread.
This may prevent correct resource cleanup after `main` completes.
This condition could be caused by executing `run` in an interactive sbt session with `fork := false`.
Set `Compile / run / fork := true` in this project to resolve this.
To silence this warning set the system property:
`-Dcats.effect.warnOnNonMainThreadDetected=false`.
[io-compute-9] INFO org.http4s.ember.server.EmberServerBuilderCompanionPlatform - Ember-Server service bound to address: [::]:8080
So I add Compile / run / fork := true as suggested in the build.sbt. Though it looks like the server process is still running, but the console prints with error saying
[error] [WARNING] IOApp `main` is running on a thread other than the main thread.
[error] This may prevent correct resource cleanup after `main` completes.
[error] This condition could be caused by executing `run` in an interactive sbt session with `fork := false`.
[error] Set `Compile / run / fork := true` in this project to resolve this.
[error] To silence this warning set the system property:
[error] `-Dcats.effect.warnOnNonMainThreadDetected=false`.
[error] [io-compute-16] INFO org.http4s.ember.server.EmberServerBuilderCompanionPlatform - Ember-Server service bound to address: [::]:8080
I remember this did not happen with sbt version like 0.13 or a version below 1.0 (Can’t remember the version I used in the past). Now I use sbt 1.11.2. Is this the possible cause? Or how do I remove that error with warning message i.e. [error] [WARNING] IOApp main ... ?
Thanks.