octobercms/october · error · ApplicationException
Unable to create directory {tempPath}
Error message
Unable to create directory {tempPath} What it means
ThemeImport::import() writes the uploaded zip to temp_path() and then creates a fresh oc* staging directory to extract into; it throws when File::makeDirectory($tempPath) returns false. This is the import-side twin of the export failure: the storage/temp directory is not writable by the PHP process, the disk is full, or the filesystem is read-only.
Source
Thrown at modules/cms/models/ThemeImport.php:124
$this->theme = $theme;
$this->fill($data);
try {
$file = $this->uploaded_file()->withDeferred($sessionKey)->first();
if (!$file) {
throw new ApplicationException('There is no file attached to import!');
}
$themePath = $this->theme->getPath();
$tempPath = temp_path() . '/'.uniqid('oc');
$zipName = uniqid('oc');
$zipPath = temp_path().'/'.$zipName;
File::put($zipPath, $file->getContents());
if (!File::makeDirectory($tempPath)) {
throw new ApplicationException('Unable to create directory '.$tempPath);
}
Zip::extract($zipPath, $tempPath);
if (File::isDirectory($tempPath.'/meta')) {
$this->copyDirectory($tempPath.'/meta', $themePath.'/meta');
}
foreach ($this->folders as $folder) {
if (!array_key_exists($folder, $this->getFoldersOptions())) {
continue;
}
$this->copyDirectory($tempPath.'/'.$folder, $themePath.'/'.$folder);
}
File::deleteDirectory($tempPath);
File::delete($zipPath);View on GitHub (pinned to b608633a7e)
Solutions
- Fix storage permissions: chown -R www-data:www-data storage && chmod -R 775 storage.
- Verify writability and space: is_writable(temp_path()) and disk_free_space(temp_path()) must both pass.
- Mount a writable volume at storage/ in containerized deployments.
- Clean stale oc* files from storage/temp and retry the import.
Example fix
# before: import throws 'Unable to create directory {tempPath}'
sudo chown -R www-data:www-data storage && sudo chmod -R 775 storage
# after
php artisan tinker
>>> is_writable(temp_path()); // true - import extracts cleanly Defensive patterns
Strategy: validation
Validate before calling
$temp = temp_path();
if (!is_writable($temp) || disk_free_space($temp) < 200 * 1024 * 1024) {
// block import: staging dir + extracted archive need writable space
} Try / catch
try {
$themeImport->import($theme, $data, $sessionKey);
} catch (ApplicationException $e) {
// report storage/temp permissions or disk space; sweep stale oc* dirs
} Prevention
- Fix storage permissions during provisioning, not after import failures.
- Size temp space for at least twice the largest theme zip (zip + extracted tree).
- Clean storage/temp of oc* leftovers from failed runs.
When it happens
Trigger: Running a theme import right after a zip upload when storage/temp is not writable, the volume is out of space (note the zip was just written, so quota may have been consumed by it), or the app runs on a read-only filesystem.
Common situations: Same environments as export failures: hardened shared hosting, read-only containers, exhausted quotas; also large archives filling the disk between File::put($zipPath) and the mkdir call.
Related errors
- Unable to create directory {tempPath}
- Unable to create directory {metaPath}
- backend::lang.media.error_creating_folder
- cms::lang.cms_object.error_creating_directory
- cms::lang.cms_object.error_saving
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/84e301318b84d474.
Report an issue: GitHub.