Skip to content
Latchkey

pytest "-p no:cacheprovider" Still Writes .pytest_cache in CI

Disabling the cache plugin with -p no:cacheprovider stops pytest writing .pytest_cache - but only if nothing re-enables it. A --lf/--ff flag, a config setting, or a plugin that depends on the cache can keep it on, and a read-only CI filesystem then errors.

What this error means

Despite -p no:cacheprovider, pytest still creates .pytest_cache (polluting the workspace), or fails with a permission/OSError writing it on a read-only filesystem. Flags or config are silently turning the cache back on.

pytest output
INTERNALERROR> OSError: [Errno 30] Read-only file system: '.pytest_cache'
# or .pytest_cache reappears even with -p no:cacheprovider

Common causes

A cache-dependent flag re-enables it

--last-failed/--failed-first (and some plugins) need the cache, so they implicitly re-activate it even when you disabled the provider.

Read-only or wrong cache directory

On a read-only CI filesystem, any cache write fails. The cache may also be pointed at a non-writable path via config.

How to fix it

Remove cache-dependent flags too

Drop --lf/--ff and any plugin that needs the cache when you truly want it off.

Terminal
pytest -p no:cacheprovider   # and no --lf/--ff

Point the cache at a writable dir

If you keep the cache, send it to a writable location (e.g. a temp dir).

Terminal
pytest -o cache_dir=/tmp/pytest_cache

How to prevent it

  • Do not combine -p no:cacheprovider with cache-dependent flags.
  • Set a writable cache_dir on read-only filesystems.
  • Decide deliberately whether CI needs the cache at all.

Related guides

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