Skip to content
Latchkey

Exit Code 2 in CI: What It Means and How to Fix It

Exit code 2 often means shell-builtin misuse - but many tools (make, grep, pytest) use it for their own errors.

Exit 2 is overloaded: Bash uses it for builtin misuse, while make/grep/pytest assign their own meanings.

What it means

Either a shell syntax/usage error, or a tool reporting its specific error class.

Common causes

  • Bash: misused builtin or syntax error.
  • make: a build error.
  • grep: no lines matched + an error.
  • pytest: test collection/usage error.

How to fix it

Identify which tool produced the 2 and check its docs; the meaning is tool-specific.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →