Skip to content
Latchkey

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.

lein
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

  1. Scroll to the "N failures, N errors" summary and the failing assertions above it.
  2. Fix the failing tests or the code under test.
  3. Re-run lein test and confirm a clean, zero-exit run.
Terminal
lein test :only myapp.core-test

Diagnose 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.

Terminal
export JVM_OPTS="-Xmx2g"
lein test

How to prevent it

  • Treat a non-zero lein test exit 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →