leiningen 无法在 os x 上运行
当我尝试在我的 os x lion 上运行 leiningen 时,出现以下错误。安装是按照 github 上的说明(自述文件)完成的。谁能给我一个提示吗?
我通过谷歌找到的唯一可能的解决方案是运行 lein clean ,但对我来说失败并出现类似的消息。
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$script_opt.invoke(main.clj:339)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at clojure.lang.Var.invoke(Var.java:409)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at leiningen.util.paths$legacy_native_path.<clinit>(paths.clj:32)
at leiningen.util.paths__init.load(Unknown Source)
at leiningen.util.paths__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.loadClassForName(RT.java:2030)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at leiningen.core$loading__4414__auto__.invoke(core.clj:1)
at leiningen.core__init.load(Unknown Source)
at leiningen.core__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.loadClassForName(RT.java:2030)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:604)
at clojure.core$use.doInvoke(core.clj:5363)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval1.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
... 11 more
When I try running leiningen on my os x lion I get the error below. The install is done as per the instructions on github (README). Can anyone give me a hint on this?
The only possible solution I found via google was to run lein clean
but that fails for me with a similar message.
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$script_opt.invoke(main.clj:339)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at clojure.lang.Var.invoke(Var.java:409)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at leiningen.util.paths$legacy_native_path.<clinit>(paths.clj:32)
at leiningen.util.paths__init.load(Unknown Source)
at leiningen.util.paths__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.loadClassForName(RT.java:2030)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at leiningen.core$loading__4414__auto__.invoke(core.clj:1)
at leiningen.core__init.load(Unknown Source)
at leiningen.core__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.loadClassForName(RT.java:2030)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:604)
at clojure.core$use.doInvoke(core.clj:5363)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval1.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
... 11 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我同意 cieplak - 我刚才遇到了同样的问题,lein 依赖于 Clojure 1.2.1,它创建的默认项目文件使我的新项目依赖于 Clojure 1.3.0。当我运行“lein test”来运行新项目 Clojure 1.3.0 的测试时,Clojure 1.3.0 已下载并添加到类路径中,然后出现了您上面所述的错误。
解决方案 - 删除我的新项目(在“libs”中)中下载的所有 jar 文件,将 project.clj 更改为依赖于 Clojure 1.2.1 以匹配 lein 并重新运行“lein test”来下载依赖关系。这次,没有 Clojure 版本冲突,也没有错误:)
更正 - 只有在每次运行 'lein test' 之前执行此操作才有效:( :(
更新 - 我已经通过确保项目中使用的所有依赖项解决了我的问题相同版本的 Clojure - 1.2.1。主要依赖项是 Midje,所以我使用其中的 1.2.0(它使用 Clojure 的 1.2.1),当然还有 Leiningen 本身的版本1.6.2 也使用 Clojure 1.2.1 这不是一个理想的情况,但至少它可以连续运行,而不必删除所有依赖库!
I agree with cieplak - I had the same problem just now, lein depends on Clojure 1.2.1 and the default project file it created made my new project depend on Clojure 1.3.0. When I ran 'lein test' to run the tests for the new project Clojure 1.3.0 was downloaded and added to the classpath and then I had the error you state above.
Solution - Delete all the downloaded jars in my new project (in 'libs'), change project.clj to depend on Clojure 1.2.1 to match lein and re-run 'lein test' to download the dependencies. This time, no Clojure version clash and no error :)
Correction - This only works if you do it before each run of 'lein test' :( :(
Update - I have fixed my problem by making sure all the dependencies in my project use the same version of Clojure - 1.2.1. The main dependencies is Midje, so I'm using 1.2.0 of that (which uses 1.2.1 of Clojure) and of course Leiningen itself at version 1.6.2 which uses Clojure 1.2.1 also. Not an ideal situation but at least it works in consecutive runs without having to delete all the dependent libraries!
这是快速判断您是否有使用不同版本 Clojure 的依赖项的好方法:
Here is a great way to quickly tell if you have dependencies that use a different version of Clojure:
确保您运行的是 java 1.6+
我在使用过时 java 的系统上运行时也遇到过类似的问题。
make sure you are running java 1.6+
I have had similar problems when running on systems with outdated java.
我现在也有同样的问题。我刚刚使用 Lein 安装了 Incanter。我通过删除 ~/.lein/plugins/incter-1.3.0-SNAPSHOT.jar 修复了它。
据我所知,该错误是由不同版本的 Clojure 的依赖项冲突引起的。就我而言,Incanter 依赖于 Clojure-1.3,而我的 Lein 使用 1.2,而我安装的 clojure 是 1.4。
I have the same problem at the moment. I just installed Incanter using Lein. I fixed it by removing ~/.lein/plugins/incanter-1.3.0-SNAPSHOT.jar.
From what I can tell, the error is caused by a conflict of dependencies on different versions of Clojure. In my case, Incanter depended on Clojure-1.3, while my Lein uses 1.2, and my installed clojure is 1.4.
在所有情况下,异常
java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
意味着您正在尝试运行针对 clojure 1.2 编译的代码,使用 Clojure 1.3。这里发生的情况是,您有一个开发依赖项,它将 clojure 1.3 拉入 lib/dev 中。 lib/dev 中的所有 jar 都会添加到类路径中。 Leiningen 包含针对 clojure 1.2 编译的代码,并且您会得到异常。
解决方案:找出哪个 dev 依赖项依赖于 clojure,并将其排除。这看起来像
[foo "1.2.0" :exclusions [org.clojure/clojure]]
如何确定哪个 dev-dep?反复试验,或者查看源代码中的project.clj。
In all cases, the exception
java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
means you're trying to run code compiled against clojure 1.2, using clojure 1.3.What's happening here is you have a dev-dependency that's pulling in clojure 1.3 into lib/dev. All of the jars in lib/dev get added to the classpath. Leiningen contains code compiled against clojure 1.2, and you get the exception.
The solution: figure out which dev-dependency is depending on clojure, and exclude it. This will look like
[foo "1.2.0" :exclusions [org.clojure/clojure]]
How do you figure out which dev-dep? Trial and error, or by looking at their project.clj in their source code.