{"record":{"id":"df415a2183b48b06","repo":"symfony/http-kernel","slug":"unable-to-create-the-store-directory-s","errorCode":null,"errorMessage":"Unable to create the store directory (%s).","messagePattern":"Unable to create the store directory \\((.+?)\\)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"HttpCache/Store.php","lineNumber":47,"sourceCode":"    /** @var array<string, resource> */\n    private array $locks = [];\n\n    /**\n     * Constructor.\n     *\n     * The available options are:\n     *\n     *   * private_headers  Set of response headers that should not be stored\n     *                      when a response is cached. (default: Set-Cookie)\n     *\n     * @throws \\RuntimeException\n     */\n    public function __construct(\n        protected string $root,\n        private array $options = [],\n    ) {\n        if (!is_dir($this->root) && !@mkdir($this->root, 0o777, true) && !is_dir($this->root)) {\n            throw new \\RuntimeException(\\sprintf('Unable to create the store directory (%s).', $this->root));\n        }\n        $this->keyCache = new \\SplObjectStorage();\n        $this->options['private_headers'] ??= ['Set-Cookie'];\n    }\n\n    /**\n     * Cleanups storage.\n     */\n    public function cleanup(): void\n    {\n        // unlock everything\n        foreach ($this->locks as $lock) {\n            flock($lock, \\LOCK_UN);\n            fclose($lock);\n        }\n\n        $this->locks = [];\n    }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/HttpCache/Store.php#L29-L65","documentation":"Store::__construct() throws RuntimeException when the cache root directory does not exist and cannot be created via recursive mkdir (permissions, read-only filesystem, or path collision). The HTTP cache cannot operate without its storage directory.","triggerScenarios":"Constructing new Store('/path/to/cache') where the parent directory is not writable, the disk is full/read-only, or mkdir fails for any reason (@ suppresses the warning, then re-check fails).","commonSituations":"Deployments where var/cache lacks write permission for the PHP user, read-only container filesystems, or NFS mounts with permission issues.","solutions":["Create the directory manually and chmod/chown it so the PHP process user can write: mkdir -p /path && chown www-data:www-data /path.","Verify the configured root path is correct and on a writable filesystem.","Check disk space and mount flags (ro vs rw) in containers."],"exampleFix":"// before\n$store = new Store('/var/cache/http_cache'); // not writable\n// after\nif (!is_dir('/var/cache/http_cache')) { mkdir('/var/cache/http_cache', 0777, true); }\nchmod('/var/cache/http_cache', 0777);\n$store = new Store('/var/cache/http_cache');","handlingStrategy":"validation","validationCode":"$root = '/var/cache/http_cache'; if ((!is_dir($root) && !@mkdir($root, 0777, true)) && !is_dir($root)) { // fail fast with clear deployment error }","typeGuard":null,"tryCatchPattern":"try { $store = new Store($root); } catch (\\RuntimeException $e) { // fall back to no-cache or abort deployment with clear message }","preventionTips":["Ensure cache dirs are created and writable at deploy time","Run PHP-FPM/CLI under a user owning var/cache","Avoid read-only root filesystems or mount a writable volume for cache"],"tags":["php","symfony","http-cache","filesystem","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}