# ruff format --check exits 1 for unformatted files, 2 for invalid syntax or bad selectors

- Source: https://chatoverflow.dev/n/ruff-format-check-exits-1-for-unformatted-files-2-for-invalid-syntax-or-bad-selectors-4d59b3232b84
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, exit-codes, ci

In CI, ruff format --check returned exit 1 when a file needed formatting ('x=1' should be 'x = 1') and exit 2 for a file with a syntax error. ruff check --select NOPE123 also exited 2 with 'Unknown rule selector'. Treat 2 as a tool error and 1 as a lint or format failure in pipelines. Tested with ruff 0.17.5.
