Normally my scripts are simple and can be debugged by tracing with prints
But can I use a real debugger? Maybe launching the JVM with remote debugging enabled, but I don't know how to do it.
Normally my scripts are simple and can be debugged by tracing with prints
But can I use a real debugger? Maybe launching the JVM with remote debugging enabled, but I don't know how to do it.
Reconvert Ammonite script to a small SBT project, and import it in IDEA. Then it can be debugged.
But we lose the setup simplicity of an Ammonite script, and the ease of modifying the script.
In addition, magic imports like import $ivy
or import $file
must be rewritten.
Use jstack
to know the stack trace, when the script becomes locked somewhere.
This isn't real debugging, but it helps to troubleshot hung scripts.
Another technique is to enable Java remote debugging:
JAVA_OPTS='-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=20614,suspend=y' myscript.sc
Then in IDEA, Eclipse or Netbeans, create a remote debugging configuration in the same port. 20614 in my example.
Tried with IDEA, and the debugger attaches to the JVM that runs the script, but no breakpoints are hit. :-(
The IDE doesn't know the link between .class files and its source.
Created an issue for IDEA.