Debug Scala with Spacemacs
The documentation about debugging in ENSIME was a bit confusing to me. Here are my notes on how to start debugging an (sbt-based) Scala project from Emacs (Spacemacs):
-
Launch the debugger from the sbt console first. Use the sbt-mode shell. I don’t really know if this works launching SBT on a terminal not running under Emacs. Use
ensimeTestOnlyDebug
if you are running a test, otherwise useensimeRunDebug
for an implementation class.> ensimeTestOnlyDebug com.company.division.squad.project.package.TestClass ... Listening for transport dt_socket at address: 5005
-
Set a breakpoint in a source code line by moving your cursor to that line and using
, d b
-
Attach to the debugger by using
, d A
. The first time, you will need to specify Host (localhost
) and Port (the number in theListening for transport ...
line above) -
When (if) the debugger hits the line where your breakpoint is set, the Emacs cursor will jump to that position, and you can start using other debugging commands (
, d n
,, d i
, etc …)