Leiningen "Subprocess failed" / lein test non-zero exit in CI
Leiningen runs many tasks in a subprocess JVM. "Subprocess failed" means that JVM exited non-zero. For lein test, a non-zero exit is the normal signal that one or more tests failed, and it correctly fails the CI step.
What this error means
lein test ends with a failure summary and "Subprocess failed (exit code 1)", or another lein task reports a failed subprocess.
Ran 42 tests containing 128 assertions.
2 failures, 0 errors.
Tests failed.
Subprocess failed (exit code 1).Common causes
Tests actually failed
For lein test, the "N failures" summary means assertions failed; the non-zero exit is the intended result, not a Leiningen bug.
The subprocess JVM crashed
An OutOfMemoryError, a fatal interop error, or a killed process makes the subprocess exit non-zero for reasons other than test assertions.
How to fix it
Read the failure summary
- Scroll to the "N failures, N errors" summary and the failing assertions above it.
- Fix the failing tests or the code under test.
- Re-run
lein testand confirm a clean, zero-exit run.
lein test :only myapp.core-testDiagnose a crashing subprocess
If there is no test failure summary, look for an OutOfMemoryError or JVM crash and raise memory or fix the interop that killed the process.
export JVM_OPTS="-Xmx2g"
lein testHow to prevent it
- Treat a non-zero
lein testexit as a real signal to fix tests. - Give the test JVM enough heap so it does not crash mid-run.
- Keep flaky tests out of the gating suite until stabilized.