Where Does Ruff Store Cache and Config?
Where Ruff keeps its per-project cache, how to relocate it elsewhere, and where the user config lives..
Last updated
Ruff caches lint results in a .ruff_cache folder inside each project by default, which keeps repeat runs fast and repos cluttered. A cache-dir setting or environment variable moves it anywhere, including the shared user cache. Config discovery walks up from the target file through three filenames.
User-level defaults live in the OS config directory when no project file exists. Explicit flags beat everything for scripts and editors. Cache contents are disposable by design; deleting them only costs one slow run.
Where Ruff stores this, by platform
<project>/.ruff_cache
Per-project lint cache beside the code by default. Move it with cache-dir or RUFF_CACHE_DIR for cleaner trees. User config falls back to the OS config dir file. Flags override both per invocation.
<project>\.ruff_cache
Same per-project default and overrides on every OS. The user config path follows platform convention through the etcetera strategy. Editors invoking Ruff inherit the project working directory.
<project>/.ruff_cache
Identical layout to Linux and Windows. Shared caches under the user cache dir suit monorepos. Delete freely; rebuilds are automatic.
Frequently asked questions
how do I clear the Ruff cache
Delete .ruff_cache folders to reclaim space; they rebuild on next run. CI systems cache them keyed on inputs for speed. The --no-cache flag skips reads for one-off debugging runs.
how do I move the cache out of my repo
Set cache-dir in config or RUFF_CACHE_DIR in the environment to move it off the project tree. Editors piling caches into repos annoy git users for good reason. The setting beats the variable when both exist.
which config file wins
Ruff walks up to the nearest pyproject, ruff.toml, or dotfile variant, falling back to defaults plus a user config when nothing matches. Explicit --config pins one file for odd layouts. The user file lives in the OS config dir by platform convention.
Notice an outdated path? Let us know.