octobercms/october · error · ApplicationException

editor::lang.filesystem.error_creating_directory

Error message

editor::lang.filesystem.error_creating_directory

What it means

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.

Source

Thrown at modules/editor/traits/FileSystemFunctions.php:48

        if (!$this->validateFileSystemPath($newName)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));
        }

        if (strlen($parent) && !$this->validateFileSystemPath($parent)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));
        }

        if (!$this->validateFileSystemName($newName)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_name'));
        }

        $newFullPath = $basePath.'/'.$parent.'/'.$newName;
        if (file_exists($newFullPath) && is_dir($newFullPath)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.already_exists'));
        }

        if (!File::makeDirectory($newFullPath, 0755, true, true)) {
            throw new ApplicationException(Lang::get(
                'editor::lang.filesystem.error_creating_directory',
                ['name' => $newName]
            ));
        }
    }

    /**
     * editorRenameFileOrDirectory
     */
    protected function editorRenameFileOrDirectory($basePath, $name, $originalPath, $allowedFileExtensions)
    {
        $newName = trim($name);
        if (!strlen($newName)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.name_cant_be_empty'));
        }

        if (!$this->validateFileSystemPath($newName)) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));

View on GitHub (pinned to b608633a7e)

Solutions

  1. 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).
  2. Check open_basedir in php.ini covers the target path.
  3. Verify no regular file already exists at the target path with the same name.
  4. Check disk space (df -h) and SELinux/audit logs if permissions look correct.

Example fix

# before
$ ls -ld themes
# drwxr-xr-x 2 root root ... themes

# after
$ chown -R www-data:www-data themes && chmod -R u+rwX themes
Defensive patterns

Strategy: try-catch

Validate before calling

if (!is_writable($basePath)) {
    throw new \ValidationException(['basePath' => 'The server cannot write to this directory - check ownership and permissions']);
}

Try / catch

try {
    if (!\File::makeDirectory($full, 0755, true, true)) {
        throw new \ApplicationException('Could not create the directory');
    }
} catch (\Exception $e) {
    \Log::error('mkdir failed for '.$full.': '.$e->getMessage());
    // surface an actionable message: permissions, open_basedir, or disk space
    throw new \ApplicationException('Directory creation failed; verify write permissions and disk space.');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/10ed8b2f15e4a800. Report an issue: GitHub.