The problem with this is that now you have to repeat your classpath in
two places: your SLIME config and the shell script that you use to
launch your app. This is a DRY[1] violation.
One solution would be to load a single file and then have that file use
add-classpath to set the classpath, but add-classpath is unreliable;
I've had problems getting it to work consistently and have been told in
#clojure that I shouldn't be using it.
My solution for the time being is to always launch via SLIME and
consider that method of launching it canonical, essentially deprecating
the method of launching it from the shell. But obviously this is not
ideal because for some reason not everyone uses Emacs. =) Clearly the
classpath belongs in the codebase so it can be used independently of how
the application was launched.
There's got to be a way around this problem, but I haven't found it yet.
-Phil
This is frustrating - with a fresh REPL I'm back to the compile
problem. I can't think of anything I changed that would cause it to
work intermittently, and I don't know what file it's looking for...
the source files are on the classpath (it "require"s just fine) and
the directory in *compile-path* is also on the cp (via add-
classpath).
It's not the "load" operation that caused it - I removed that entirely
and just put a placeholder (defn foo [] true), and the compilation
still crashes on this line.
> Clojure developers, would it be a good idea for Compiler.java or
> clojure.core/compile to check if *compile-path* exists, else throw
> an exception specific to that problem?
I like the idea. There is a subtle problem I don't think it will catch
though. The JRE appears to scan CLASSPATH only once at startup
checking whether each item in it is actually a viable jar file or
directory. If a path appears in CLASSPATH, but does not exist at JRE
startup, but does exist at compile time, compilation will still fail
and it will still be very hard to figure out why.
Perhaps this is a case for speculation in the error message:
- Exception: Compilation target directory doesn't exist
- Exception: Compilation target directory exists, but load-after-
compile failed, did it exist when the JVM was launched?
(assuming the latter is detectable)
--Steve
> Connect to your running app from emacs by using "M-x slime-connect"
> rather than "M-x slime". When you're done, use "M-x slime-
> disconnect" (or from the REPL, "," then "disconnect") to leave your
> process running. In addtion, including swank in your running
> production app is a real benefit since you can connect to it from
> emacs at any later time for diagnosis, debugging, etc...
That's good to know; thanks.
I'm still a little uneasy about introducing swank as an external
dependency. It's not a big deal for stuff you'd use internally, but for
open-source projects I like to keep the installation process to a couple
lines. I guess I could bundle a copy of swank-clojure to streamline
things.
Or I could wait until I actually have something to release before I
obsess about making installation and distribution easy. =)
-Phil