Clojure "Could not locate X on classpath" (deps.edn) in CI
A require asked for a namespace whose file or providing library is not on the classpath built from deps.edn. Clojure reports it cannot locate the .clj/.cljc or compiled __init.class.
What this error means
A run fails with "Execution error ... Could not locate <path>__init.class, <path>.clj or <path>.cljc on classpath" naming the namespace.
clojure
Execution error (FileNotFoundException) at ...
Could not locate cheshire/core__init.class, cheshire/core.clj or
cheshire/core.cljc on classpath.Common causes
The dependency is not declared in deps.edn
The required namespace lives in a library missing from :deps, so its files are not on the classpath.
A source path is not on the classpath
A local namespace exists but its directory is not in :paths, so the compiler cannot find the file.
How to fix it
Add the dependency to deps.edn
- Read which namespace could not be located.
- Add the library that provides it to
:deps. - Re-run with the right alias so the classpath includes it.
deps.edn
{:deps {cheshire/cheshire {:mvn/version "5.13.0"}}}Add the source directory to :paths
For a local namespace, ensure its directory is on :paths so the file is on the classpath.
deps.edn
{:paths ["src" "resources"]}How to prevent it
- Declare every required library in
:deps. - Keep
:pathscovering all source and resource directories. - Run the same alias locally and in CI so the classpath matches.
Related guides
Clojure "ClassNotFoundException" (deps.edn) in CIFix Clojure "java.lang.ClassNotFoundException: X" in CI - code referenced a Java class that is not on the cla…
Clojure "Syntax error compiling: Unable to resolve symbol" in CIFix Clojure "Syntax error compiling at ... Unable to resolve symbol: X in this context" in CI - the compiler…
Clojure Leiningen "Could not find artifact" in CIFix Clojure Leiningen "Could not find artifact X in central/clojars" in CI - lein reached its repositories bu…