octobercms/october · error · ApplicationException
editor::lang.filesystem.error_deleting_dir
Error message
editor::lang.filesystem.error_deleting_dir
What it means
Thrown by editorDeleteFileOrDirectory when @rmdir() fails on a directory that was just confirmed empty (lines 147-152). Message: 'Error deleting directory :name.'. An empty directory whose removal fails means the PHP user lacks write permission on the directory's PARENT (removing a dir modifies the parent's entry), or a race where something recreated a file between the isDirectoryEmpty check and rmdir.
Source
Thrown at modules/editor/traits/FileSystemFunctions.php:148
if (!File::isDirectory($fullPath)) {
if (!@File::delete($fullPath)) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.error_deleting_file',
['name' => $path]
));
}
}
else {
$empty = File::isDirectoryEmpty($fullPath);
if (!$empty) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.error_deleting_dir_not_empty',
['name' => $path]
));
}
if (!@rmdir($fullPath)) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.error_deleting_dir',
['name' => $path]
));
}
}
}
}
}
/**
* editorMoveFilesOrDirectories
*/
protected function editorMoveFilesOrDirectories($basePath, $selectedList, $destinationDir)
{
if (!count($selectedList)) {
throw new ApplicationException(Lang::get('editor::lang.filesystem.selected_files_not_found'));
}
View on GitHub (pinned to b608633a7e)
Solutions
- Make the PARENT directory writable by the PHP user (chown/chmod the folder that contains the directory being deleted)
- Stop build watchers or other writers, refresh, and retry the delete
- Check SELinux/AppArmor if standard permissions look fine
- Retry once after a refresh — the emptiness check may have raced a transient file
Example fix
# before: parent owned by root $ sudo chown -R www-data:www-data themes/demo/assets # then retry the delete in the Editor
Defensive patterns
Strategy: try-catch
Validate before calling
$full = $assetsBase.'/'.$path;
if (is_dir($full) && !is_writable(dirname($full))) {
// rmdir needs write on the PARENT directory — fix it first
} Try / catch
try {
if (!@rmdir($fullPath)) {
throw new ApplicationException(Lang::get('editor::lang.filesystem.error_deleting_dir', ['name' => $path]));
}
} catch (ApplicationException $e) {
// possible race: re-check emptiness and retry once
clearstatcache(true, $fullPath);
if (!is_dir($fullPath)) { return; } // someone else removed it
throw $e;
} Prevention
- Keep parent directories writable by the webserver user
- Stop file watchers before bulk-deleting asset folders
- Retry once after a refresh — a writer may have raced the emptiness check
When it happens
Trigger: command_onAssetDelete on an empty dir under themes/<theme>/assets when the parent directory is root-owned or not writable by the webserver user; SELinux denying rmdir; a background process (build, watcher) recreating files inside the directory at the moment of deletion.
Common situations: Assets directory tree created by root deploys but served/edited by www-data; platform permission drift after moving a project between users; dev watchers (webpack --watch, vite) continuously writing output into asset folders.
Related errors
- editor::lang.filesystem.error_renaming
- editor::lang.filesystem.error_deleting_file
- editor::lang.filesystem.error_moving_file
- editor::lang.filesystem.error_moving_directory
- editor::lang.filesystem.destination_not_found
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/41bfe6362539dc92.
Report an issue: GitHub.