{"record":{"id":"8fbc9f450da16a21","repo":"pathwaycom/pathway","slug":"no-persistent-storage-configured-for-the-disk-cach","errorCode":null,"errorMessage":"no persistent storage configured for the disk cache","messagePattern":"no persistent storage configured for the disk cache","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/pathway/internals/udfs/caches.py","lineNumber":98,"sourceCode":"            cache = self._get_cache(func)\n            key = self.make_key(args, kwargs)\n            if cache is None:\n                return func(*args, **kwargs)\n            if key not in cache:\n                result = func(*args, **kwargs)\n                cache[key] = result\n            return cache[key]\n\n        return wrapper\n\n    def _get_cache(self, func: Callable) -> diskcache.Cache | None:\n        if self._cache is None:\n            if self._name is None:\n                func = inspect.unwrap(func)\n                self._name = f\"{func.__module__}_{func.__qualname__}\"\n            storage_root = os.environ.get(\"PATHWAY_PERSISTENT_STORAGE\")\n            if storage_root is None:\n                raise RuntimeError(\n                    \"no persistent storage configured for the disk cache\"\n                )\n            cache_dir = Path(storage_root) / \"runtime_calls\"\n            self._cache = diskcache.Cache(\n                cache_dir / self._name, size_limit=self._size_limit\n            )\n        return self._cache\n\n\nclass DefaultCache(DiskCache):\n    \"\"\"\n    The default caching strategy.\n    Persistence layer will be used if enabled. Otherwise, cache will be disabled.\n    \"\"\"\n\n    def _get_cache(self, func: Callable) -> diskcache.Cache | None:\n        if \"PATHWAY_PERSISTENT_STORAGE\" not in os.environ:\n            return None","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/udfs/caches.py#L80-L116","documentation":"RuntimeError raised lazily (on first cache access, not at construction) when a disk cache needs a persistent directory but the PATHWAY_PERSISTENT_STORAGE environment variable is unset. The cache directory is derived as $PATHWAY_PERSISTENT_STORAGE/runtime_calls/<cache_name>.","triggerScenarios":"Using pw.udfs.DiskCache (or DefaultCache) in a UDF without setting PATHWAY_PERSISTENT_STORAGE. The error surfaces on the first UDF call when _get_cache runs, which can be deep inside pipeline execution, far from the configuration mistake.","commonSituations":"Running a pipeline in a new environment/container/CI without the env var; copying code that worked locally (where the var was set in .env or shell) to a deployment; notebooks where the env var was set in another kernel.","solutions":["Set PATHWAY_PERSISTENT_STORAGE to a writable directory before starting the process: export PATHWAY_PERSISTENT_STORAGE=/path/to/storage","Or configure persistence via pw.persistence.Config(...) which sets the storage root","In containers/CI, inject the variable in the entrypoint or compose file","If persistence is not needed, use an in-memory cache strategy instead of DiskCache"],"exampleFix":"// before\nPATHWAY_PERSISTENT_STORAGE unset; @pw.udf(cache_strategy=pw.udfs.DiskCache()) -> RuntimeError on first call\n\n// after\nexport PATHWAY_PERSISTENT_STORAGE=/var/lib/pathway\npython run_pipeline.py","handlingStrategy":"validation","validationCode":"import os\n\ndef assert_persistent_storage_configured():\n    root = os.environ.get('PATHWAY_PERSISTENT_STORAGE')\n    if not root:\n        raise RuntimeError(\n            'Set PATHWAY_PERSISTENT_STORAGE to a writable dir before using disk caches'\n        )\n    return root","typeGuard":null,"tryCatchPattern":"try:\n    result = udf(x)\n    pw.run()\nexcept RuntimeError as e:\n    if 'no persistent storage' in str(e):\n        os.environ['PATHWAY_PERSISTENT_STORAGE'] = './persist'\n        pw.run()\n    else:\n        raise","preventionTips":["Set PATHWAY_PERSISTENT_STORAGE in the process entrypoint before building pipelines","Add a startup check for the env var in deployments and CI","Configure persistence explicitly with pw.persistence.Config"],"tags":["pathway","udf","cache","environment","configuration"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}