Welcome! Please see the About page for a little more info on how this works.

0 votes
in Errors by


Whichever github project I run I get the same error.

Now I have started a simple example from the book clojure for brave and true and the same program appears.

(ns clojure-noob.core (:gen-class))

(defn -main "I don't do a whole lot ... yet." [& args] (println "I'm a little teapot!"))

error is > PS C:\Users\danny\New folder\cftbat-code> lein run
No :main namespace specified in project.clj.

what can i do and what i am doing wrong?

1 Answer

0 votes

You need to tell lein which namespace has the -main function that you want to run: probably clojure-noob.core. You might think your program has only 1 namespace, but in fact it will have several, including for example clojure.core, clojure.repl, clojure.main, etc., in addition to whatever your project contains.

The command lein help run will give instructions on how to specify the ns to run.

Thanks , i tried and i got this

PS C:\Users\danny> lein run core.clj
No :main namespace specified in project.clj.
PS C:\Users\danny> lein help run
Run the project's -main function.

USAGE: lein run [--] [ARGS...]
Calls the -main function in the namespace specified as :main in project.clj.
You may use -- to escape the first argument in case it begins with `-' or `:'.
If your main function is not called "-main", you may use a namespaced symbol
like clojure.main/main.

Calls the main function in the specified namespace. You may have to use -- to
escape the first argument in case it begins with `-' or `:'.

The `--quote-args' flag quotes the arguments passed in, instead of converting
them to strings. Arguments coming from the command line will always be strings,
so this is only useful when invoked from :aliases.
It needs to be the fully-qualified namespace:

lein run -m clojure-noob.core

Or you could add the following to your project.clj file:

:main clojure-noob.core