Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve symbol when running code using Leiningen

I'm using Leiningen (for the first time) to manage an app my writing. So far I've defined the project dependencies, installed the deps in the project lib directory, and I've defined a function. When I run lein repl from the project root and then call the function I've defined, I get the error unable to resolve symbol. Anyone know what I'm doing wrong and how to correctly run my app via Leiningen? Thanks.

like image 585
sjac Avatar asked Jul 21 '11 21:07

sjac


2 Answers

from the leiningen repl you will have to switch to the namespace your function was defined in with the in-ns macro.

(in-ns 'myproject.core)

then the function should be available
you could also use that namespace from the repl to include it in the default (user) namespace.

(use 'myproject.core)

after that you may want to consider looking into the lein run, lein uberjar, and lein jar leiningen tasks.

like image 115
Arthur Ulfeldt Avatar answered Nov 13 '22 13:11

Arthur Ulfeldt


In my projects, for a core.clj file which contains a namespace defined thus:

(ns my-project.core)

... I set the :main key in Leiningen's defproject map in project.clj:

(defproject my-project "1.0.0-SNAPSHOT"
  :description "My project description"
  :dependencies [[org.clojure/clojure "1.2.1"]]
  :main my-project.core)

So when I run lein repl, my core namespace is automatically loaded, and I see this:

mac:my-project scott$ lein repl
REPL started; server listening on localhost:31515.
my-project.core=> 
like image 31
Scott Avatar answered Nov 13 '22 11:11

Scott