Question

After upgrading Leiningen (from v1.6 to v1.7) with lein upgrade command lein swank stopped working with error message:

Exception in thread "main" java.lang.NoClassDefFoundError:  
Caused by: java.lang.ClassNotFoundException:  
[...] 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class:  .  Program will exit.

Since I tried it from command line, I believe Emacs configuration doesn't matter in this case. So I tried to re-install Leiningen completely. What I've done (using suggestions from here and error messages):

rm -R ~/.m2
# rm ~/.lein/plugins/*  
lein self-install

(I used second line on second reinstallation only, so it is here for the sake of completeness)

Then I created new project and installed lein-swank plugin, since, as far as I understand, it is recommended way at the moment:

lein new test-project
lein plugin install swank-clojure 1.4.0  # I tried earlier version (1.3.2) too

And finally started lein swank with:

cd test-project
lein swank

But got same error as before.

So my questions are:

  1. How to fix this problem?
  2. Do I reinstall Leiningen correctly or some steps are missing?

UPD. Here's project.clj generated with new project:

(defproject test-project "1.0.0-SNAPSHOT"
   :description "FIXME: write description"
   :dependencies [[org.clojure/clojure "1.3.0"]])
Was it helpful?

Solution

Does the swank-clojure troubleshooting page help:

Troubleshooting

Currently having multiple versions of swank-clojure on the classpath can cause issues when running lein swank or lein jack-in. It's recommended to not put swank-clojure in your :dev-dependencies but run lein plugin install to have it installed globally for all projects instead. This also means that people hacking on your project won't have to pull it in if they are not Emacs users.

It's also possible for some packages to pull in old versions of swank-clojure transitively, so check the lib/ directory if you are having issues. In particular, Incanter is known to exhibit this problem. Judicious use of :exclusions make it work:

:dependencies [[incanter "1.2.3" :exclusions [swank-clojure]]]

Since swank-clojure 1.3.4, having versions of clj-stacktrace older than 0.2.1 in your project or user-level plugins will cause Unable to resolve symbol: pst-elem-str errors. Keep in mind that user-level plugins in ~/.lein/plugins are uberjars in Leiningen 1.x, so it's possible that one of your plugins (such as lein-difftest before version 1.3.7) contains an old clj-stacktrace even if it doesn't have its own file there. Specifying a newer version should be enough if you're having trouble:

:dependencies [[clj-stacktrace "0.2.4"]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top