Why do incanter, other than incanter itself, namespaces expecting clojure/core/matrix class or .clj?

462 Views Asked by At

In a .clj file I have (use '(incanter core io ...)). This error occurs when attempting to evaluate that code: FileNotFoundException Could not locate clojure/core/matrix__init.class or clojure/core/matrix.clj on classpath: clojure.lang.RT.load (RT.java:443). If I change the code to just this: (use '(incanter)), then all is OK except that none of the necessary namespaces are available, which is to be expected. I have been using jEdit with the clojure plugin quite happily for the past 18 months and closely verified that my classpath was OK. I tried (use '...math.combinatorics) and the csv & json jars (these all worked OK) to be reasonably sure it wasn't a jEdit config problem. I looked for 'matrix' in the clojure/core jar, but did not find it. Any help to solve this problem greatly appreciated.

After further investigation: I think I have found the source of my problem: in the clatrix-0.3.0 namespace declaration clojure.core.matrix is required. When I remove clatrix from the classpath and evaluate (use '(incanter core ...)) this error occurs: FileNotFoundException Could not locate clatrix/core__init.class or clatrix/core.clj on classpath: clojure.lang.RT.load (RT.java:443). When clatrix is added to the classpath then my original error occurs (i.e. can't find clojure.core.matrix). Incanter-core does have a Matrix.class file. It seems incanter depends on clatrix which depends on clojure.core. matrix which doesn't exist. How does one solve this problem or is there a work-around?

1

There are 1 best solutions below

2
On

The problem here is that you are not providing the transitive dependencies for your library. clojure.core.matrix is not part of clojure.core. Clearly whatever method Jedit uses for running Clojure does not detect or resolve your dependencies for you.

While this dependency resolution can be done by hand, it is a less error prone task, and less time consuming, to let leiningen resolve your dependencies and set up your class path during development, and use the lein repl task to start your interactive repl during development. Lein repl starts an nrepl server, which has a well defined API that multiple editors / programming environments can connect to. A good editor for clojure development should provide some method of connecting to an nrepl server.