How to use project namespace in SLIME REPL

567 views Asked by At

I've installed lein with the swank plugin, Emacs, SLIME, and clojure-mode, and created a new project using lein new. I've called the project clojure-test. I then open clojure_test/src/clojure_test/core.clj in Emacs, and while in this file call M-x clojure-jack-in. This opens up a SLIME window, which works fine; I can load code using C-c C-l, switch into my project namespace using C-c M-p, and use dependencies that I've added to the project.

The problem arises when, from the "user" namespace, I attempt to use the namespace for the project itself. Calling (use 'clojure-test) inside of SLIME from the "user" namespace results in the following error:

Could not locate clojure_test__init.class or clojure_test.clj on classpath:
[Thrown class java.io.FileNotFoundException]
  1. Why does Clojure search for these files? The namespace is apparently already loaded, as I can switch into it via C-c M-p, but for some reason Clojure thinks these particular files are important to using the namespace.

  2. How do I setup my project so that I can use the base namespace from SLIME? Since lein is supposed to take care of this, what information am I not giving it that it needs?

1

There are 1 answers

1
Joost Diepenmaat On BEST ANSWER

The namespace "clojure-test" should be in ./src/clojure_test.clj (./src is in the classpath by default unless you changed it in your project.clj file)

Did you put it in src/clojure_test/core.clj (which should have ns clojure-test.core instead) ?

See the documentation for libs at http://clojure.org/libs