Leiningen "Syntax error macroexpanding" in CI
A macro received a form it could not expand. The arguments do not fit the macro shape, so expansion fails before the resulting code compiles.
What this error means
Compilation fails with Syntax error macroexpanding clojure.core/defn at (app.clj:6:1), naming the macro. It is deterministic.
lein
Syntax error macroexpanding clojure.core/defn at (app.clj:6:1).
(foo [x] ...) - failed: vector? at: [:fn-tail :arity-1 :params]Common causes
Macro called with the wrong shape
The argument vector or body does not match what the macro (defn, let, deftest) expects, so its spec fails during expansion.
Misused or nested macro
A macro is used in a position or nesting it does not support, producing an invalid expansion.
How to fix it
Match the macro shape
Provide the arguments in the form the macro expects.
app.clj
(defn foo [x]
(* x x))Read the spec failure path
- Note the
at:path in the message to see which part is wrong. - Compare your form to the macro docstring.
- Use macroexpand-1 at the REPL to inspect the expansion.
How to prevent it
- Follow macro arglists exactly.
- Lint with clj-kondo to catch shape errors.
- Test macro-heavy code at the REPL before pushing.
Related guides
Clojure "Syntax error compiling at" in CIFix the Clojure "Syntax error compiling at (file:line:col)" error in CI - unbalanced forms, bad arity, or inv…
Clojure "Unable to resolve symbol" in CIFix the Clojure "Unable to resolve symbol: X in this context" compile error in CI when a symbol is not define…
sbt "Not a valid command" in CIFix the sbt "Not a valid command" / "Expected" error in CI when an sbt invocation passes a task or command sb…