Leiningen "No :main namespace specified" in CI
Leiningen needs a :main namespace to know which entry point to run or bake into an uberjar. When lein run or lein uberjar runs and :main is absent, there is nothing to launch.
What this error means
lein run fails with "No :main namespace specified. See lein help run." or the uberjar builds without a runnable entry point.
No :main namespace specified in project.clj.
See `lein help run`.Common causes
project.clj declares no :main
The :main key is missing, so lein run has no default namespace to execute.
The main namespace lacks a -main and gen-class
For an uberjar, the entry namespace must define -main and (:gen-class) so a runnable class is produced.
How to fix it
Declare the main namespace
- Add
:maintoproject.cljpointing at your entry namespace. - Ensure that namespace defines
-mainand(:gen-class). - Run
lein runto confirm the entry point launches.
(defproject myapp "0.1.0"
:main ^:skip-aot myapp.core
:dependencies [[org.clojure/clojure "1.11.1"]])Define the entry point
Give the main namespace a -main function and gen-class so it can run and be AOT compiled for an uberjar.
(ns myapp.core (:gen-class))
(defn -main [& args] (println "started"))How to prevent it
- Set
:maininproject.cljfor runnable projects. - Define
-mainwith(:gen-class)in the entry namespace. - Test
lein runlocally before relying on it in CI.