{"record":{"id":"f5b02d02c2221f71","repo":"octobercms/october","slug":"unable-to-create-directory-temppath","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/ThemeExport.php","lineNumber":110,"sourceCode":"        $this->attributes['theme'] = $theme;\n    }\n\n    /**\n     * export\n     */\n    public function export($theme, $data = [])\n    {\n        $this->theme = $theme;\n        $this->fill($data);\n\n        try {\n            $themePath = $this->theme->getPath();\n            $tempPath = temp_path() . '/'.uniqid('oc');\n            $zipName = uniqid('oc');\n            $zipPath = temp_path().'/'.$zipName;\n\n            if (!File::makeDirectory($tempPath)) {\n                throw new ApplicationException('Unable to create directory '.$tempPath);\n            }\n\n            if (!File::makeDirectory($metaPath = $tempPath . '/meta')) {\n                throw new ApplicationException('Unable to create directory '.$metaPath);\n            }\n\n            File::copy($themePath.'/theme.yaml', $tempPath.'/theme.yaml');\n            File::copyDirectory($themePath.'/meta', $metaPath);\n\n            foreach ($this->folders as $folder) {\n                if (!array_key_exists($folder, $this->getFoldersOptions())) {\n                    continue;\n                }\n\n                File::copyDirectory($themePath.'/'.$folder, $tempPath.'/'.$folder);\n            }\n\n            Zip::make($zipPath, $tempPath);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeExport.php#L92-L128","documentation":"ThemeExport::export() stages a copy of the theme under a fresh temp_path()/oc* directory before zipping it. It throws when File::makeDirectory($tempPath) returns false, meaning the PHP process could not create a directory inside storage/temp. Since the path is uniquid-generated per run, this is an environment failure (permissions, disk space, read-only filesystem), not a name collision.","triggerScenarios":"Triggering a theme export (backend CMS > Themes > export, which calls ThemeExport::export()) when the web-server user lacks write permission on storage/temp, the disk or quota is exhausted, or the app runs on a read-only container filesystem.","commonSituations":"Shared hosting where storage/ was uploaded without write permissions; Docker deploys with read-only app volumes; disk quota hit; open_basedir restrictions excluding temp_path().","solutions":["Give the PHP user write access to storage: chown -R www-data:www-data storage then chmod -R 775 storage.","Confirm writability: php artisan tinker, then is_writable(temp_path()); - must be true.","Check free space and inodes (df -h, df -i) and clean up storage/temp if full.","In containers, mount a writable volume at storage/ so temp_path() resolves to writable storage."],"exampleFix":"# before: export fails - PHP cannot mkdir under storage/temp\nls -ld storage/temp   # root:root 755\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 - export succeeds","handlingStrategy":"validation","validationCode":"$temp = temp_path();\n\nif (!is_dir($temp) && !@mkdir($temp, 0775, true)) {\n    throw new RuntimeException(\"{$temp} cannot be created - fix storage permissions\");\n}\nif (!is_writable($temp)) {\n    // block the export with an actionable message\n}\nif (disk_free_space($temp) < 100 * 1024 * 1024) {\n    // block the export: low disk\n}","typeGuard":null,"tryCatchPattern":"try {\n    $token = ThemeExport::export($theme, $data);\n} catch (ApplicationException $e) {\n    // message names the failing path - report storage/temp permissions,\n    // then clean partially created temp_path()/oc* directories\n}","preventionTips":["Make storage/ writable (775, owned by the PHP-FPM user) as part of deployment, not after the first failure.","Monitor free disk space - exports stage a full theme copy plus a zip.","Never run the app on a read-only filesystem without a writable volume mounted at storage/."],"tags":["filesystem","permissions","theme-export","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"}