{"record":{"id":"0a3f6ee7d7a8d9e6","repo":"octobercms/october","slug":"unable-to-create-directory-metapath","errorCode":null,"errorMessage":"Unable to create directory {metaPath}","messagePattern":"Unable to create directory (.+?)","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/cms/models/ThemeExport.php","lineNumber":114,"sourceCode":"     * 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);\n            File::deleteDirectory($tempPath);\n        }\n        catch (Exception $ex) {\n            if (strlen($tempPath) && File::isDirectory($tempPath)) {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeExport.php#L96-L132","documentation":"The second makeDirectory() in ThemeExport::export() creates the {tempPath}/meta staging subdirectory for the theme's meta folder. The parent directory was just created successfully, so a failure here means the ability to write was lost mid-flow (quota hit between the two calls, permissions changed, security software interference) or a file named meta already blocks the path.","triggerScenarios":"Running a theme export where the first mkdir under storage/temp succeeds but the meta subdir creation returns false - mid-export quota exhaustion, concurrent hardening of permissions, or a leftover file named meta inside the freshly generated oc* temp path.","commonSituations":"Disk quota that fills while copying a large theme; concurrent exports racing for space; container storage quotas; rarely, a corrupted temp path from a previous interrupted run.","solutions":["Free space in storage/temp (delete stale oc* directories) and retry the export.","Re-verify permissions and quota on the storage volume: the oc* parent was created, so look for quota/inode limits or a conflicting 'meta' entry inside it.","Remove partially created temp_path()/oc* directories before retrying so the run starts clean.","If it recurs, inspect system logs for the underlying mkdir errno (permissions vs ENOSPC)."],"exampleFix":"# before: mid-export failure - 'Unable to create directory {tempPath}/meta'\nfind storage/temp -maxdepth 1 -name 'oc*' -exec rm -rf {} +\ndf -h storage   # ensure free space\n\n# after: retry export - fresh oc* staging tree builds cleanly","handlingStrategy":"validation","validationCode":"$temp = temp_path();\nif (!is_writable($temp) || disk_free_space($temp) < 100 * 1024 * 1024) {\n    // abort export before it starts staging meta/\n}","typeGuard":null,"tryCatchPattern":"try {\n    $token = ThemeExport::export($theme, $data);\n} catch (ApplicationException $e) {\n    // mid-export failure: sweep stale oc* dirs in temp_path() and free space/quota before retry\n}","preventionTips":["Keep storage/temp clear of stale oc* directories from interrupted runs.","Watch quota/inode limits on the storage volume, not just byte usage.","Alert on any export failure so a mid-flow permission/quota change is caught early."],"tags":["filesystem","permissions","theme-export","storage","quota"],"backgroundTag":"temp-directory-creation-failed","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}