This condition could be caused by executing `run` in an interactive sbt session with `fork := false`

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.

Did you reloaded before running again?

Not quite sure. Do you mean sbt will reload the process automatically? I did not reload e.g. wait until the sbt process that watched the build.sbt was changed or something similar.

I merely stopped sbt process by ctrl + c. Then I modified build.sbt, copying/ pasting the suggested Compile / run / fork :=true from the console. Next, restarting the sbt process again by sbt server/run.

Please let me know if more information is needed. Thanks.

sbt has a command called reload, you need to run it every time you change the build.sbt for those changes to take effect.