Snippet: turn on JVM debugging in sbt

| 1 minute | comments

Remote debugging can be used to debug externally executed programs, useful to activate in sbt in order to keep using it while debugging with your favorite IDE. See for example IntelliJ IDEA’s documentation:

UPDATE: there is now a --jvm-debug <port> parameter to the sbt executable …

sbt --jvm-debug 5005

OLD WAY: — if the above is not suitable, you can do a manual config like this:

fork := true

javaOptions ++= {
  val Digits = "^(\\d+)$".r
  sys.env.get("JVM_DEBUG") match {
    case Some("true") =>
    case Some(Digits(port)) =>
    case _ =>

And then set a JVM_DEBUG environment variable, before executing sbt:

JVM_DEBUG=5005 sbt
| Written by
Tags: sbt | Scala | Snippet