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
Exit Codes and Signals in CI/CD: A Practical GuideA practical guide to process exit codes and signals in CI/CD - what 1, 2, 124, 126, 127, 130, 137, and 143 me…
CI Exit Code Lookup: What Does This Exit Code Mean?Instant lookup for CI/CD process exit codes - enter a code (137, 127, 143…) to see what it means, whether it…