Swank Deploys
SLIME and SWANK are incredible. Start a SWANK server in your application and Whammo! You've can connect to it from the comfort of Emacs. From there you can tinker with its insides to your heart's content. This is a beta-testing dream!
Except when it isn't. Recently I deployed a Common Lisp web application where I ran into some trouble.
Trouble The First: Connection Error
So say that my service is running on server.com
and SWANK is listening on port 4040
. Then to connect to it I have been using ssh port forwarding:
ssh -L 4040:localhost:4040 me@server.com
So that I can then do slime-connect
with localhost
and 4040
as its arguments.
You might be surprised, however if you were to have used the following ssh command, which lists the local host ip of 127.0.0.1
, instead of localhost
:
ssh -L 4040:127.0.0.1:4040 me@server.com
For whatever reason, this fails: ssh reports a connection error. So, I had to use localhost
explicitly.
Trouble The Second: SWANK-REQUIRE
The second, and more irksome issue comes up when I actually succeed at connecting via slime-connect
: I immediately drop into the slime debugger. The issue seems to be that SWANK
is trying to load some code upon connection. Obviously, it is not going to be able to load code unless that code is present and available on the server.
In order to get the required code into the deployed binary, I do the following prior to executing save-lisp-and-die
:
(swank:swank-require
'(SWANK-IO-PACKAGE::SWANK-INDENTATION
SWANK-IO-PACKAGE::SWANK-TRACE-DIALOG
SWANK-IO-PACKAGE::SWANK-PACKAGE-FU
SWANK-IO-PACKAGE::SWANK-PRESENTATIONS
SWANK-IO-PACKAGE::SWANK-MACROSTEP
SWANK-IO-PACKAGE::SWANK-FUZZY
SWANK-IO-PACKAGE::SWANK-FANCY-INSPECTOR
SWANK-IO-PACKAGE::SWANK-C-P-C
SWANK-IO-PACKAGE::SWANK-ARGLISTS
SWANK-IO-PACKAGE::SWANK-REPL))
I got the list of required modules directly from the SLIME
debugger. I recompiled, redeployed, and ta-dah! It works!
#commonlisp #emacs