{"record":{"id":"10ed8b2f15e4a800","repo":"octobercms/october","slug":"editor-lang-filesystem-error-creating-directory","errorCode":null,"errorMessage":"editor::lang.filesystem.error_creating_directory","messagePattern":"editor::lang\\.filesystem\\.error_creating_directory","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/editor/traits/FileSystemFunctions.php","lineNumber":48,"sourceCode":"        if (!$this->validateFileSystemPath($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));\n        }\n\n        if (strlen($parent) && !$this->validateFileSystemPath($parent)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));\n        }\n\n        if (!$this->validateFileSystemName($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_name'));\n        }\n\n        $newFullPath = $basePath.'/'.$parent.'/'.$newName;\n        if (file_exists($newFullPath) && is_dir($newFullPath)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.already_exists'));\n        }\n\n        if (!File::makeDirectory($newFullPath, 0755, true, true)) {\n            throw new ApplicationException(Lang::get(\n                'editor::lang.filesystem.error_creating_directory',\n                ['name' => $newName]\n            ));\n        }\n    }\n\n    /**\n     * editorRenameFileOrDirectory\n     */\n    protected function editorRenameFileOrDirectory($basePath, $name, $originalPath, $allowedFileExtensions)\n    {\n        $newName = trim($name);\n        if (!strlen($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.name_cant_be_empty'));\n        }\n\n        if (!$this->validateFileSystemPath($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/editor/traits/FileSystemFunctions.php#L30-L66","documentation":"The last step of editorCreateDirectory calls File::makeDirectory($newFullPath, 0755, true, true) and checks the return value. PHP's mkdir returning false means the server could not create the directory, and editor::lang.filesystem.error_creating_directory is thrown. Unlike the earlier guards, this is a server-side environment failure, not bad input.","triggerScenarios":"The web server user lacks write permission on basePath (typical theme directory); open_basedir restriction excludes the target; disk full or inode exhaustion; SELinux denying writes; a file (not directory) already occupies the exact name so recursive mkdir fails.","commonSituations":"Fresh deploy where themes/ is owned by root or the deploy user instead of the web server user; containerized setups with read-only volumes; shared hosting with restrictive open_basedir; CI environments running the editor API.","solutions":["Give the web server user write access to the base path: chown -R www-data:www-data themes/ or adjust group ownership and permissions (e.g. 775 with correct group).","Check open_basedir in php.ini covers the target path.","Verify no regular file already exists at the target path with the same name.","Check disk space (df -h) and SELinux/audit logs if permissions look correct."],"exampleFix":"# before\n$ ls -ld themes\n# drwxr-xr-x 2 root root ... themes\n\n# after\n$ chown -R www-data:www-data themes && chmod -R u+rwX themes","handlingStrategy":"try-catch","validationCode":"if (!is_writable($basePath)) {\n    throw new \\ValidationException(['basePath' => 'The server cannot write to this directory - check ownership and permissions']);\n}","typeGuard":null,"tryCatchPattern":"try {\n    if (!\\File::makeDirectory($full, 0755, true, true)) {\n        throw new \\ApplicationException('Could not create the directory');\n    }\n} catch (\\Exception $e) {\n    \\Log::error('mkdir failed for '.$full.': '.$e->getMessage());\n    // surface an actionable message: permissions, open_basedir, or disk space\n    throw new \\ApplicationException('Directory creation failed; verify write permissions and disk space.');\n}","preventionTips":["Make theme/base paths writable by the web server user at deploy time (provisioning, not manual fix).","Mount volumes read-write in containers that host the editor.","Monitor disk space and open_basedir settings in health checks."],"tags":["editor","filesystem","permissions","deployment"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}