{"record":{"id":"8234f5f1373ef25b","repo":"phalcon/cphalcon","slug":"meta-data-directory-cannot-be-written","errorCode":null,"errorMessage":"Meta-Data directory cannot be written","messagePattern":"Meta-Data directory cannot be written","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\MetaData\\Exceptions\\MetaDataDirectoryNotWritable","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/MetaData/Stream.zep","lineNumber":100,"sourceCode":"\n        try {\n            let path = this->metaDataDir . prepare_virtual_path(key, \"_\") . \".php\";\n\n            if false === this->phpFilePutContents(path, \"<?php return \" . var_export(data, true) . \"; \") {\n                this->throwWriteException(option);\n            }\n        } catch \\Exception {\n            this->throwWriteException(option);\n        }\n    }\n\n    /**\n     * Throws an exception when the metadata cannot be written\n     */\n    private function throwWriteException(var option) -> void\n    {\n        if option {\n            throw new MetaDataDirectoryNotWritable();\n        } else {\n            trigger_error(\n                \"Meta-Data directory cannot be written\"\n            );\n        }\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":108,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/MetaData/Stream.zep#L82-L108","documentation":"Stream::write() failed to persist the compiled meta-data PHP file into metaDataDir (phpFilePutContents returned false or threw), so throwWriteException() raises MetaDataDirectoryNotWritable. This is a filesystem permission/path failure, and any wrapped exception is swallowed and replaced by this sentinel error.","triggerScenarios":"Thrown at phalcon/Mvc/Model/MetaData/Stream.zep:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the meta-data directory writable by the web-server user (chown/chmod)","Check disk space and open_basedir/safe-path restrictions","Point the meta-data dir option to a valid, writable path"],"exampleFix":"chmod 775 /var/cache/phalcon-metadata && chown www-data:www-data /var/cache/phalcon-metadata","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision and verify the storage directory during deployment","Cache to a dedicated writable cache volume instead of code directories"],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}