title: clojure classpath(?) troubles loading code and dependencies with leiningen
body: <p>I'm a Clojure and JVM beginner, and the build tools are a bit confusing to me, so forgive the stupidity I'm about to carry out.  I don't actually know what a "classpath" is... I just want a Lisp with lots of libraries!  </p>
  
  <p>But I'm trying to do a write a simple little bit of text-mining code in Clojure, and I don't seem to be able to get things working.</p>
  
  <p>There are two problems, and I think they're related, both probably to this classpath thing from javaland that none of the introductory Clojure books seem to explain.</p>
  
  <p>I started the project with <code>lein new</code> and my project.clj has the following dependencies:</p>
  
  <pre><code> :dependencies [[org.clojure/clojure "1.6.0"] 
                   [clj-fuzzy "0.1.8"]
                   [snowball-stemmer "0.1.0"]
                   [net.mikera/core.matrix "0.50.0"]])
  </code></pre>
  
  <p>and the relevant ns call from my core.clj is as follows:</p>
  
  <pre><code>(ns blabber.core 
    (:require 
      [clojure.string :refer [lower-case split]]
      [clojure.walk :refer [keywordize-keys]]))
  </code></pre>
  
  <p>My directory structure is the default setup leiningen uses for a new library.</p>
  
  <p><strong>First problem</strong>: </p>
  
  <p>I gather from this prior <a href="https://stackoverflow.com/questions/7658981/how-to-reload-a-clojure-file-in-repl">SO</a> that if things are set up right, I shouldn't need to call <code>(load-file "src/blabber/core.clj")</code> in the repl before calling <code>(use 'blabber.core)</code> in order to get at code I just wrote. (I'm firing up the lein repl from the src/blabber directory in bash). But when I fire up the repl, use fails unless I call load-file first.  So does that mean my classpath is set up wrong somehow?  And how does one fix such a thing?</p>
  
  <p><strong>Second problem</strong>:</p>
  
  <p>Ok, so now I'm trying to actually use core.matrix.  First line of my core.clj changed to:</p>
  
  <pre><code>(ns blabber.core 
    (:require 
      [clojure.string :refer [lower-case split]]
      [clojure.walk :refer [keywordize-keys]]
      [clojure.core.matrix :refer [dataset]]))
  </code></pre>
  
  <p>When I first started the repl with this project.clj but without the <code>:require</code> to core.matrix, leiningen happily fetched core.matrix: <code>Retrieving net/mikera/core.matrix/0.50.0/core.matrix-0.50.0.jar from clojars</code></p>
  
  <p>However, after including the <code>:require</code> to core.matrix in the actual code and starting up the repl again, at the repl I call <code>(load-file "src/blabber/core.clj")</code>, and get the following error: </p>
  
  <blockquote>
    <p>CompilerException java.io.FileNotFoundException: Could not locate clojure/core/matrix__init.class or clojure/core/matrix.clj on classpath: , compiling:(/Users/pauliglot/github/blabber/src/blabber/core.clj:1:1)</p>
  </blockquote>
  
  <p>I'm using Leiningen 2.5.1 on Java 1.8.0_45.  And I'm just following the <a href="https://github.com/mikera/core.matrix/wiki/Getting-Started-Guide" rel="nofollow noreferrer">getting started guide</a> for core.matrix.</p>
  
  <p>So what happened? Why can't the JVM find any of my stuff? Save me? Thanks!</p>
  
  <p>If it helps, here's a dump of the output of <code>lein classpath</code></p>
  
  <blockquote>
    <p>/Users/pauliglot/github/blabber/test:/Users/pauliglot/github/blabber/src:/Users/pauliglot/github/blabber/dev-resources:/Users/pauliglot/github/blabber/resources:/Users/pauliglot/github/blabber/target/classes:/Users/pauliglot/.m2/repository/clj-fuzzy/clj-fuzzy/0.1.8/clj-fuzzy-0.1.8.jar:/Users/pauliglot/.m2/repository/snowball-stemmer/snowball-stemmer/0.1.0/snowball-stemmer-0.1.0.jar:/Users/pauliglot/.m2/repository/org/clojure/tools.macro/0.1.5/tools.macro-0.1.5.jar:/Users/pauliglot/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar:/Users/pauliglot/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20140226-71326067/google-closure-library-third-party-0.0-20140226-71326067.jar:/Users/pauliglot/.m2/repository/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar:/Users/pauliglot/.m2/repository/org/clojure/google-closure-library/0.0-20140226-71326067/google-closure-library-0.0-20140226-71326067.jar:/Users/pauliglot/.m2/repository/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar:/Users/pauliglot/.m2/repository/org/json/json/20090211/json-20090211.jar:/Users/pauliglot/.m2/repository/net/mikera/core.matrix/0.50.0/core.matrix-0.50.0.jar:/Users/pauliglot/.m2/repository/com/google/javascript/closure-compiler/v20131014/closure-compiler-v20131014.jar:/Users/pauliglot/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/Users/pauliglot/.m2/repository/org/clojure/clojurescript/0.0-2202/clojurescript-0.0-2202.jar:/Users/pauliglot/.m2/repository/args4j/args4j/2.0.16/args4j-2.0.16.jar:/Users/pauliglot/.m2/repository/org/clojure/tools.nrepl/0.2.6/tools.nrepl-0.2.6.jar:/Users/pauliglot/.m2/repository/com/google/guava/guava/15.0/guava-15.0.jar:/Users/pauliglot/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar:/Users/pauliglot/.m2/repository/org/clojure/tools.reader/0.8.3/tools.reader-0.8.3.jar:/Users/pauliglot/.m2/repository/org/clojure/data.json/0.2.3/data.json-0.2.3.jar</p>
  </blockquote>
  
  <p><strong>Edit</strong>
  Here's the directory tree: 
    | blabber
     |-doc
     |-resources
     |-src
     |---blabber
     |-target
     |---classes
     |-----META-INF
     |-------maven
     |---------blabber
     |-----------blabber
     |---stale
     |-test</p>
  
  <p>and all my code is in blabber/src/blabber/core.clj</p>