{"record":{"id":"84e301318b84d474","repo":"octobercms/october","slug":"unable-to-create-directory-temppath-84e301","errorCode":null,"errorMessage":"Unable to create directory {tempPath}","messagePattern":"Unable to create directory (.+?)","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/cms/models/ThemeImport.php","lineNumber":124,"sourceCode":"\n        $this->theme = $theme;\n        $this->fill($data);\n\n        try {\n            $file = $this->uploaded_file()->withDeferred($sessionKey)->first();\n            if (!$file) {\n                throw new ApplicationException('There is no file attached to import!');\n            }\n\n            $themePath = $this->theme->getPath();\n            $tempPath = temp_path() . '/'.uniqid('oc');\n            $zipName = uniqid('oc');\n            $zipPath = temp_path().'/'.$zipName;\n\n            File::put($zipPath, $file->getContents());\n\n            if (!File::makeDirectory($tempPath)) {\n                throw new ApplicationException('Unable to create directory '.$tempPath);\n            }\n\n            Zip::extract($zipPath, $tempPath);\n\n            if (File::isDirectory($tempPath.'/meta')) {\n                $this->copyDirectory($tempPath.'/meta', $themePath.'/meta');\n            }\n\n            foreach ($this->folders as $folder) {\n                if (!array_key_exists($folder, $this->getFoldersOptions())) {\n                    continue;\n                }\n\n                $this->copyDirectory($tempPath.'/'.$folder, $themePath.'/'.$folder);\n            }\n\n            File::deleteDirectory($tempPath);\n            File::delete($zipPath);","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeImport.php#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: import throws 'Unable to create directory {tempPath}'\nsudo chown -R www-data:www-data storage && sudo chmod -R 775 storage\n\n# after\nphp artisan tinker\n>>> is_writable(temp_path());   // true - import extracts cleanly","handlingStrategy":"validation","validationCode":"$temp = temp_path();\nif (!is_writable($temp) || disk_free_space($temp) < 200 * 1024 * 1024) {\n    // block import: staging dir + extracted archive need writable space\n}","typeGuard":null,"tryCatchPattern":"try {\n    $themeImport->import($theme, $data, $sessionKey);\n} catch (ApplicationException $e) {\n    // report storage/temp permissions or disk space; sweep stale oc* dirs\n}","preventionTips":["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."],"tags":["filesystem","permissions","theme-import","storage","temp-directory"],"backgroundTag":"temp-directory-creation-failed","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}