Question

I made a project named my-stuff and added to the project.clj so it looks like this

(defproject my-stuff "0.1.0-SNAPSHOT"
  :description "Testing lein"
  :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"] [clj-http "0.5.5"]]
  :main my-stuff.core)

so i can run the core however when I try to run lein run i get this

Learning\my-stuff>lein run
Exception in thread "main" java.lang.Exception: Cannot find anything to run for:
 my-stuff.core
    at user$eval5.invoke(form-init5159589073116828284.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6619)
    at clojure.lang.Compiler.eval(Compiler.java:6609)
    at clojure.lang.Compiler.load(Compiler.java:7064)
    at clojure.lang.Compiler.loadFile(Compiler.java:7020)
    at clojure.main$load_script.invoke(main.clj:294)
    at clojure.main$init_opt.invoke(main.clj:299)
    at clojure.main$initialize.invoke(main.clj:327)
    at clojure.main$null_opt.invoke(main.clj:362)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
    \Clojure\Learning\my-stuff>

even tho the core does exist in the source.

what do i do?

Was it helpful?

Solution

Setting the :main key in the project.clj file directs Leiningen to run the -main function in the specified namespace. It is not included in the default lein template, so you need to add it.

(ns my-stuff.core)

(defn -main [& args]
  (println "Working!"))

OTHER TIPS

In my case "src/my-stuff/core.clj" file didn't have a "-main" method instead it was

(ns my-stuff.core)

(defn foo [& args]
  (println "Working!"))

I had to change "foo" to "-main".

Just another note - In my case I had a few entry points with -main in my haste I had copied the (ns ... from another file and forgot to change it.

project/core.clj
(ns project.core ...)

project/app.clj
(ns project.core ...) <-- oops

So double just check that the :main you specified actually exists in your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top