-
Notifications
You must be signed in to change notification settings - Fork 25
Arity Exception when calling add-hook #15
Comments
Can't reproduce, perhaps I've got the wrong idea. (ns dire-error.core
(:require [robert.hooke :as r]
[dire.core :as d]))
(defn foo
[x]
x)
(defn microscope
[f x]
(inc x))
(r/add-hook #'foo java.lang.ArithmeticException #'microscope) Project file: (defproject dire-error "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[dire "0.4.4"]
[robert/hooke "1.3.0"]]) |
It is a strange error for sure. I'm reaching for straws here. Could there be some coflict with another library? Or development setting? My project.clj right now is: (defproject admin "0.1" |
I don't see |
Okay, fixed now. Sorry for the trouble. I had to run "lein clean". I notice that the code from 2 years ago: Back then, add-hook only took 2 arguments. When I started my current project, the project had that old version of hooke. I've tried and tried to delete that old version, but it was in the system somewhere. And yet this: lein tree :deps only showed hooke 1.3. Which confused me, because I thought if "lein tree :deps" didn't show an old version, then I must have been free of the old version. But clearly, the ghost of hooke 1.2 was in the code somewhere. And "lein clean" fixed the problem. |
Maybe a problem in |
Ha! I like the poster you link to. I agree, there was some disparity between what "lein tree" showed me and what was actually there. When I have time, and if I can reproduce, I will file a bug with Leinengen. |
Sounds good. |
This originally started because I introduced Dire to a project, which had an out of date version of robert-hooke. But I updated the dependencies, which I though would fix the problem, but it does not.
If I:
(ns admin.views
(:use [taoensso.timbre :as timbre :only (trace debug info warn error fatal spy)]
[robert.hooke]))
and:
(add-hook #'process-programmer-designer-contract java.lang.ArithmeticException #'microscope)
And then, in emacs, I try:
nrepl-jack-in
which gives me:
Exception in thread "main" java.lang.ExceptionInInitializerError
...Caused by: clojure.lang.ArityException: Wrong number of args (3) passed to: hooke$add-hook
If I look here:
https://github.com/technomancy/robert-hooke/blob/master/src/robert/hooke.clj
I see:
(defn add-hook
"Add a hook function f to target-var. Hook functions are passed the
target function and all their arguments and must apply the target to
the args if they wish to continue execution."
([target-var f](add-hook target-var f f))
([target-var key f](prepare-for-hooks target-var)
(possibly-record-in-scope target-var)
(swap! (hooks target-var) assoc key f)))
This clearly accepts 3 args.
If I try to do it like this:
(ns admin.views
(:require [robert.hooke :as hooke]))
(hooke/add-hook #'process-programmer-designer-contract java.lang.ArithmeticException #'microscope)
I get the same error.
I can call add-hook with 2 arguments and that works just fine:
(hooke/add-hook #'process-programmer-designer-contract #'microscope)
If I do this:
lein deps :tree
The only dependencies I see are the ones I expect:
[cheshire "5.1.1"]
[com.fasterxml.jackson.core/jackson-core "2.1.4"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.1.4"]
[clj-time "0.4.4"]
[joda-time "2.1"]
[com.cemerick/friend "0.1.5"]
[com.google.inject/guice "2.0"]
[aopalliance "1.0"]
[commons-codec "1.6"]
[net.sourceforge.nekohtml/nekohtml "1.9.10"]
[xerces/xercesImpl "2.8.1"]
[xml-apis "1.3.03"]
[org.apache.httpcomponents/httpclient "4.2.1"]
[org.apache.httpcomponents/httpcore "4.2.1"]
[org.clojure/core.cache "0.6.2"]
[org.clojure/core.incubator "0.1.1"]
[org.mindrot/jbcrypt "0.3m"]
[org.openid4java/openid4java-nodeps "0.9.6" :exclusions [[com.google.code.guice/guice]]]
[commons-logging "1.1.1"]
[net.jcip/jcip-annotations "1.0"]
[ring/ring-core "1.2.0-beta1"]
[commons-fileupload "1.2.2"]
[commons-io "2.4"]
[javax.servlet/servlet-api "2.5"]
[ring/ring-codec "1.0.0"]
[com.novemberain/monger "1.4.2"]
[clojurewerkz/support "0.10.0"]
[com.google.guava/guava "12.0"]
[com.google.code.findbugs/jsr305 "1.3.9"]
[com.novemberain/validateur "1.2.0"]
[org.mongodb/mongo-java-driver "2.10.1"]
[ragtime/ragtime.core "0.3.0"]
[org.clojure/tools.cli "0.2.2"]
[com.taoensso/timbre "1.2.0"]
[clj-stacktrace "0.2.5"]
[compojure "1.1.5"]
[clout "1.0.1"]
[org.clojure/tools.macro "0.1.0"]
[dire "0.4.4"]
[robert/hooke "1.3.0"]
[slingshot "0.10.3"]
[enlive "1.0.1"]
[org.ccil.cowan.tagsoup/tagsoup "1.2"]
[formative "0.7.0"]
[jkkramer/verily "0.5.4"]
[org.clojure/clojurescript "0.0-1843"]
[com.google.javascript/closure-compiler "r2180"]
[args4j "2.0.16"]
[com.google.protobuf/protobuf-java "2.4.1"]
[com.googlecode.jarjar/jarjar "1.1"]
[org.apache.ant/ant "1.8.2"]
[org.apache.ant/ant-launcher "1.8.2"]
[org.json/json "20090211"]
[org.clojure/google-closure-library "0.0-2029-2"]
[org.clojure/google-closure-library-third-party "0.0-2029-2"]
[org.mozilla/rhino "1.7R4"]
[prismatic/dommy "0.1.1"]
[crate "0.2.3" :scope "dev"]
[prismatic/cljs-test "0.0.5"]
[fs "1.3.2"]
[org.apache.commons/commons-compress "1.3"]
[org.clojure/clojure "1.5.1"]
[org.clojure/data.json "0.2.0"]
[org.clojure/java.classpath "0.2.0"]
[org.clojure/tools.namespace "0.2.3"]
[ring/ring-jetty-adapter "1.1.5"]
[org.eclipse.jetty/jetty-server "7.6.1.v20120215"]
[org.eclipse.jetty.orbit/javax.servlet "2.5.0.v201103041518"]
[org.eclipse.jetty/jetty-continuation "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-http "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-io "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-util "7.6.1.v20120215"]
[ring "1.1.5"]
[ring/ring-devel "1.1.5"]
[hiccup "1.0.0"]
[ns-tracker "0.1.2"]
[ring/ring-servlet "1.1.5"]
Any thoughts about what is going wrong?
If I run "lein uberjar" it seems to compile, but at the repl it blows up.
The text was updated successfully, but these errors were encountered: