Clojure "Unable to resolve symbol" in CI
At compile time Clojure could not resolve a symbol to any var, local binding, or imported class. Almost always the namespace is not required, the alias is wrong, or the symbol is misspelled.
What this error means
Compilation fails with "Syntax error compiling at (file.clj:LINE). Unable to resolve symbol: X in this context".
clj
Syntax error compiling at (myapp/handler.clj:8:16).
Unable to resolve symbol: response in this contextCommon causes
A missing or wrong require/alias
The var comes from another namespace that is not :required, or the alias used does not match the one declared in ns.
A typo or an out-of-scope local
The symbol is misspelled, or it refers to a binding that is not in scope at that point.
How to fix it
Add the require and use the right alias
- Identify which namespace defines the symbol.
- Add it to the
:requirein thensform with a consistent alias. - Reference the symbol via that alias and recompile.
src/myapp/handler.clj
(ns myapp.handler
(:require [ring.util.response :as response]))
(response/response "ok")Correct the symbol or scope
If the symbol is a typo or an out-of-scope local, fix the name or move it into scope so the compiler can resolve it.
How to prevent it
- Keep
nsrequires and aliases in sync with the symbols you use. - Run clj-kondo, which flags unresolved symbols before compilation.
- Recompile changed namespaces locally before pushing.
Related guides
Clojure "Syntax error compiling" / "Error loading namespace" in CIFix "Syntax error compiling" and "Error loading namespace" in CI - the Clojure compiler failed to load a name…
Clojure lint failing the build: clj-kondo / cljfmt / cljstyle in CIFix Clojure lint and format steps failing CI - clj-kondo findings, cljfmt/cljstyle formatting differences exi…
Clojure "ClassNotFoundException" / "NoClassDefFoundError" in CIFix Clojure "java.lang.ClassNotFoundException" and "NoClassDefFoundError" in CI - a Java class the code uses…