Skip to content
Latchkey

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.

lein
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

  1. Add :main to project.clj pointing at your entry namespace.
  2. Ensure that namespace defines -main and (:gen-class).
  3. Run lein run to confirm the entry point launches.
project.clj
(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.

src/myapp/core.clj
(ns myapp.core (:gen-class))
(defn -main [& args] (println "started"))

How to prevent it

  • Set :main in project.clj for runnable projects.
  • Define -main with (:gen-class) in the entry namespace.
  • Test lein run locally before relying on it in CI.

Frequently asked questions

What causes ""No :main namespace specified""?
The :main key is missing, so lein run has no default namespace to execute.
How do I fix "No :main namespace specified"?
Declare the main namespace

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card