传递给的参数数量错误:repl$repl
我无法理解我不理解的复合“入门”示例。当我从 http://weavejester.github.com/compojure/ 运行示例时docs/getting-started.html
...我在 lein repl 步骤中收到以下错误:
~/hello-www> lein repl src/hello_www/core.clj
Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args passed to: repl$repl (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5359)
at clojure.lang.Compiler.eval(Compiler.java:5311)
at clojure.core$eval__4350.invoke(core.clj:2364)
at clojure.main$eval_opt__6502.invoke(main.clj:228)
at clojure.main$initialize__6506.invoke(main.clj:247)
at clojure.main$script_opt__6526.invoke(main.clj:263)
at clojure.main$main__6544.doInvoke(main.clj:347)
at clojure.lang.RestFn.invoke(RestFn.java:483)
at clojure.lang.Var.invoke(Var.java:381)
at clojure.lang.AFn.applyToHelper(AFn.java:180)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Wrong number of args passed to: repl$repl
at clojure.lang.AFn.throwArity(AFn.java:439)
at clojure.lang.AFn.invoke(AFn.java:43)
at clojure.lang.Var.invoke(Var.java:369)
at clojure.lang.AFn.applyToHelper(AFn.java:165)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.core$apply__3776.invoke(core.clj:535)
at leiningen.core$_main__59$fn__61.invoke(core.clj:94)
at leiningen.core$_main__59.doInvoke(core.clj:91)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at clojure.core$apply__3776.invoke(core.clj:535)
at leiningen.core$_main__59.invoke(core.clj:97)
at user$eval__67.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5343)
... 11 more
我尝试了 lein 的稳定版本和开发版本,但没有成功。关于我下一步可以寻找什么有什么想法吗?我在 linux 和 cygwin 上得到相同的结果。
当我手动运行它时,它似乎在 Linux 上运行良好:
java -cp "lib/*" clojure.main src/hello_www/core.clj
2010-05-17 19:34:17.280::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2010-05-17 19:34:17.281::INFO: jetty-6.1.14
2010-05-17 19:34:17.382::INFO: Started [email protected]:8080
I have a trouble with a compojure "Getting started" example that I do notunderstand. When I run the example from http://weavejester.github.com/compojure/docs/getting-started.html
...I get the following error at the lein repl step:
~/hello-www> lein repl src/hello_www/core.clj
Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args passed to: repl$repl (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5359)
at clojure.lang.Compiler.eval(Compiler.java:5311)
at clojure.core$eval__4350.invoke(core.clj:2364)
at clojure.main$eval_opt__6502.invoke(main.clj:228)
at clojure.main$initialize__6506.invoke(main.clj:247)
at clojure.main$script_opt__6526.invoke(main.clj:263)
at clojure.main$main__6544.doInvoke(main.clj:347)
at clojure.lang.RestFn.invoke(RestFn.java:483)
at clojure.lang.Var.invoke(Var.java:381)
at clojure.lang.AFn.applyToHelper(AFn.java:180)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Wrong number of args passed to: repl$repl
at clojure.lang.AFn.throwArity(AFn.java:439)
at clojure.lang.AFn.invoke(AFn.java:43)
at clojure.lang.Var.invoke(Var.java:369)
at clojure.lang.AFn.applyToHelper(AFn.java:165)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.core$apply__3776.invoke(core.clj:535)
at leiningen.core$_main__59$fn__61.invoke(core.clj:94)
at leiningen.core$_main__59.doInvoke(core.clj:91)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at clojure.core$apply__3776.invoke(core.clj:535)
at leiningen.core$_main__59.invoke(core.clj:97)
at user$eval__67.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5343)
... 11 more
I have tried both the stable and the developer version of lein without any success. Any ideas on what I could look for next? I get the same result both on linux and cygwin.
When I run it manually, it seems to work fine on linux:
java -cp "lib/*" clojure.main src/hello_www/core.clj
2010-05-17 19:34:17.280::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2010-05-17 19:34:17.281::INFO: jetty-6.1.14
2010-05-17 19:34:17.382::INFO: Started [email protected]:8080
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑到你对这个问题的评论——相关部分是“使用 lein-stable 可以工作,但不能使用 git 的 master”。 -- 我想说的是,Leiningen 对 2010 年 4 月 16 日提交
44b6369aec1e23bcda1db1b6570a03ca524464e5
中引入的repl
任务的新处理方式让您感到震惊。Leiningen1.1 于 2 月 16 日发布并以旧方式执行操作,这意味着
repl
任务由lein
脚本专门处理; post-44b6369aec
Leiningen 处理repl
任务的方式与所有其他任务相同,即通过leiningen.repl/repl
函数。后者根本不接受额外的参数,因此您会看到与数量相关的IllegalArgumentException
。在你问之前,我不确定这种情况将来是否会改变。应该有效的是
lein repl
后跟(require 'hello-www.core)
;然而遗憾的是,Leiningen 的 HEAD 似乎存在问题,导致其无法工作(至少在我的盒子上)。可以肯定的是,它最终会得到修复,但目前,只需使用 lein-stable 即可。 Compojure 教程使用的是 Clojure 1.1,而不是前沿技术……以同样的方式对待 Leiningen 可能会节省您一些时间。Taking into account your comment on the question -- the relevant part is "With lein-stable it works, but not with master from git." -- I'd say that you're being hit by Leiningen's new handling of the
repl
task introduced in commit44b6369aec1e23bcda1db1b6570a03ca524464e5
from 16th April 2010.Leiningen 1.1 was released on 16th February and does things the old way, which means the
repl
task is handled specially by thelein
script; post-44b6369aec
Leiningen handles therepl
task the same way as all the others, i.e. through theleiningen.repl/repl
function. The latter simply doesn't accept additional arguments, hence the arity-relatedIllegalArgumentException
that you're seeing. Before you ask, I'm not sure if that is likely to change in the future.What should work is
lein repl
followed by(require 'hello-www.core)
; regrettably, however, there seems to be an issue with Leiningen's HEAD which prevents that from working (at least on my box). It's a safe bet to expect that it's going to get fixed eventually, but for the time being, just uselein-stable
. That Compojure tutorial uses Clojure 1.1 and not the bleeding edge... It might save you some time to treat Leiningen the same way.