Skip to content
Latchkey

ruff "invalid rule selector" in CI

ruff validated the rule codes in your select/ignore config and found one it does not recognize. The code was removed, renamed, or belongs to a different ruff version than the one CI installed.

What this error means

ruff exits with "error: invalid rule selector: X123" (or "Unknown rule selector"), naming the offending code from your configuration.

python
ruff failed
  Cause: invalid rule selector: `TCH001`
  (did you mean `TC001`? the rule was renamed)

Common causes

A rule was renamed or removed

ruff evolves its rule set; codes get renamed (e.g. a prefix change) or dropped, so an old code becomes invalid.

Version skew between config and installed ruff

The config targets a ruff version with a rule that the CI-installed version does not have.

How to fix it

Update the rule code or remove it

  1. Read the suggested replacement in the error (ruff often names the new code).
  2. Update the selector in your config, or drop a removed rule.
  3. Re-run ruff.
pyproject.toml
[tool.ruff.lint]
select = ["E", "F", "TC"]   # was TCH, renamed to TC

Pin ruff to match your config

Pin a ruff version whose rule set matches the codes you configured.

Terminal
pip install "ruff==0.5.0"

How to prevent it

  • Pin the ruff version so rule codes stay valid across runs.
  • Track ruff release notes for renamed/removed rules when upgrading.
  • Run ruff check locally with the same pinned version as CI.

Related guides

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