Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running clojure with leiningen

Tags:

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?

like image 538
user2150839 Avatar asked Sep 17 '13 19:09

user2150839


People also ask

Does Leiningen install Clojure?

Most Clojure projects are still built using Leiningen.

How do you run Leiningen?

In all cases, download the file, make it executable if necessary, and then it's ready to use. The first time the script is run it will download the rest of the Leiningen application, and then this will be cached from this point forward: $ ./lein Downloading Leiningen to /Users/user/. lein/self-installs/leiningen-2.8.

How do I launch REPL in Clojure?

To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.


1 Answers

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!"))
like image 126
Jared314 Avatar answered Sep 21 '22 20:09

Jared314