diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 4d30a9920..c2cbb74f9 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -141,23 +141,31 @@ private[sbt] object xMain { private def getSocketOrExit( configuration: xsbti.AppConfiguration - ): (Option[BootServerSocket], Option[Exit]) = - try (Some(new BootServerSocket(configuration)) -> None) + ): (Option[BootServerSocket], Option[Exit]) = { + def printThrowable(e: Throwable): Unit = { + println("sbt thinks that server is already booting because of this exception:") + e.printStackTrace() + } + + try Some(new BootServerSocket(configuration)) -> None catch { case e: ServerAlreadyBootingException if System.console != null && !ITerminal.startedByRemoteClient => - println("sbt thinks that server is already booting because of this exception:") - e.printStackTrace() + printThrowable(e) println("Create a new server? y/n (default y)") val exit = if (ITerminal.get.withRawInput(System.in.read) == 'n'.toInt) Some(Exit(1)) else None (None, exit) - case _: ServerAlreadyBootingException => + case e: ServerAlreadyBootingException => if (SysProp.forceServerStart) (None, None) - else (None, Some(Exit(2))) + else { + printThrowable(e) + (None, Some(Exit(2))) + } case _: UnsatisfiedLinkError => (None, None) } + } } final class ScriptMain extends xsbti.AppMain {