How can I enable remote debugging for SBT in windows?

10,206

Solution 1

Seems like the Windows version of SBT doesn't define this functionality.

On Linux it is defined in the $SBT_HOME/sbt/bin/sbt-launch-lib.bash as

addDebugger () {   
  addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" 
}

You can achieve the same result by setting the SBT_OPTS environmental variable on Windows.

Run SBT like this, to make the debugger listen on port 5005

set SBT_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" && sbt

Solution 2

set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
sbt run

was the only working solution on Windows 7.

Solution 3

Currently, I'd downloaded the last updated sbt, exactly sbt 1.3.3 but when I want to enable debug in the project, I had the same problem as you. Investigating, I could see that I haven't this file (sbt-launch-lib.bash) in my own root C:\Program Files (x86)\sbt\bin so when I see in another machine, I could notice that sbt, It was 1.2.8 and yes it had the file that I mentioned before so I uninstalled sbt 1.3.3 and I installed sbt 1.2.8 and put in my project sbt -jvm-debug 9999 and it works.

Share:
10,206
user1875195
Author by

user1875195

Updated on June 17, 2022

Comments

  • user1875195
    user1875195 about 2 years

    I would like to accomplish running the equivalent of this

    sbt -jvm-debug 5005
    

    However I don't seem to be able to pass in args in Windows. This is what I am seeing

    >sbt -jvm-debug 5005
    [info] Loading project definition from [myProject]
    [info] Set current project to [myProject] (in build file myProject)
    [error] Expected letter
    [error] Expected symbol
    [error] Expected '!'
    [error] Expected '+'
    [error] Expected '++'
    [error] Expected ';'
    [error] Expected end of input.
    [error] Expected 'show'
    [error] Expected '*'
    [error] Expected '{'
    [error] Expected project ID
    [error] Expected configuration
    [error] Expected key
    [error] 5005
    [error] ^
    [error] Not a valid command: jvm-debug
    [error] Not a valid project ID: jvm-debug
    [error] Expected ':' (if selecting a configuration)
    [error] Not a valid key: jvm-debug
    [error] jvm-debug
    [error]          ^                  
    

    I would like to be able to remote debug this application from Intellij. Any help would be great!

  • Mike Beckerle
    Mike Beckerle over 9 years
    What does that "&& sbt" at the end of the line mean? doesn't seem like a valid option to me.
  • lpiepiora
    lpiepiora over 9 years
    On Linux it executes second command (sbt in this case) if the first command succeeded. Maybe in fact this doesent work on Windows (I dont remember, and I cannot check now). However just skip && and eexecute set and sbt as two separate commands. One after another.
  • Florian R. Klein
    Florian R. Klein over 3 years
    Does not work (anymore?) on Windows 10 and sbt version 1.3.13.