lein升级后,lein swank无法工作。

3

在使用lein upgrade命令将Leiningen(从v1.6升级到v1.7)后,lein swank停止工作,并显示以下错误消息:

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.

由于我已经尝试过命令行,我相信在这种情况下Emacs配置并不重要。因此,我尝试彻底重新安装Leiningen。以下是我的操作(使用这里和错误信息提供的建议):

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

我只在第二次重新安装时使用了第二行,所以这里为了完整性而保留。

然后我创建了一个新项目并安装了lein-swank插件,因为据我所知,这是目前推荐的方法:

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

最后,使用以下命令启动 lein swank:

cd test-project
lein swank

但是我得到了之前相同的错误。

因此,我的问题是:

  1. 如何解决这个问题?
  2. 我是否正确地重新安装了Leiningen或者有一些步骤遗漏了?

更新:这里是使用新项目生成的project.clj

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

错误信息没有说哪个类找不到吗?请把这个信息加到你的帖子里。另外,能否请你发布一下你的 project.clj 文件。 - liwp
@liwp:不,错误信息就像片段中一样 - 没有类,只有空格和点。 project.clj 是由Leiningen生成的,没有修改。完全是新项目。请注意,从那时起,我已经转移到另一台笔记本电脑上,并且全新的Leinigen安装完美地工作。 - ffriend
我仍然想知道你的 project.clj 文件指定了 Clojure 1.2.1 还是 1.3.0。 - liwp
@liwp:这是1.3.0版本。请查看我的更新以获取完整的project.clj文件(如果仍然有意义的话)。 - ffriend
1个回答

1

Swank-Clojure的故障排除页面是否有帮助:

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"]]

谢谢您的回答,但是我已经重新安装了Leinigen并创建了全新的项目。因此这些建议不适用(除非有一些我没有注意到的Leiningen依赖项)。无论如何,感谢相关答案的支持。 - ffriend
我记得最近过去的某个时候,我不得不添加clj-stacktrace作为依赖项才能使事情正常运行,但是在Leiningen 1.7.0和swank-clojure 1.4.0中似乎不再需要了。很抱歉我不能提供更多帮助。我建议像之前一样删除所有东西,包括lein脚本,并从头开始。 - liwp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接