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
- Read the suggested replacement in the error (ruff often names the new code).
- Update the selector in your config, or drop a removed rule.
- Re-run ruff.
pyproject.toml
[tool.ruff.lint]
select = ["E", "F", "TC"] # was TCH, renamed to TCPin 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 checklocally with the same pinned version as CI.
Related guides
ruff lint errors / "would reformat" failing CIFix ruff failing CI with lint violations or "would reformat" - ruff found rule violations or formatting diffe…
mypy "Skipping analyzing X: module is installed but missing stubs" in CIFix mypy "Skipping analyzing X: module is installed, but missing library stubs or py.typed marker" in CI - th…
black "would reformat" (--check failed) in CIFix black "would reformat" failing CI under --check - black found files whose formatting differs from its sty…