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.
INTERNALERROR> OSError: [Errno 30] Read-only file system: '.pytest_cache'
# or .pytest_cache reappears even with -p no:cacheproviderCommon 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.
pytest -p no:cacheprovider # and no --lf/--ffPoint the cache at a writable dir
If you keep the cache, send it to a writable location (e.g. a temp dir).
pytest -o cache_dir=/tmp/pytest_cacheHow to prevent it
- Do not combine
-p no:cacheproviderwith cache-dependent flags. - Set a writable
cache_diron read-only filesystems. - Decide deliberately whether CI needs the cache at all.