{"record":{"id":"223b67c2390c0b9b","repo":"eyaltoledano/claude-task-master","slug":"failed-to-create-directory-dirpath-error-mes","errorCode":null,"errorMessage":"Failed to create directory ${dirPath}: ${error.message}","messagePattern":"Failed to create directory (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-operations.ts","lineNumber":232,"sourceCode":"\tasync getStats(filePath: string) {\n\t\treturn fs.stat(filePath);\n\t}\n\n\t/**\n\t * Read directory contents\n\t */\n\tasync readDir(dirPath: string): Promise<string[]> {\n\t\treturn fs.readdir(dirPath);\n\t}\n\n\t/**\n\t * Create directory recursively\n\t */\n\tasync ensureDir(dirPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t} catch (error: any) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to create directory ${dirPath}: ${error.message}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete file\n\t */\n\tasync deleteFile(filePath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.unlink(filePath);\n\t\t} catch (error: any) {\n\t\t\tif (error.code !== 'ENOENT') {\n\t\t\t\tthrow new Error(`Failed to delete file ${filePath}: ${error.message}`);\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-operations.ts#L214-L250","documentation":"ensureDir() wraps fs.mkdir(dirPath, { recursive: true }) failures into 'Failed to create directory <path>: <reason>'. Recursive mkdir rarely fails on missing parents, so this almost always means an OS-level obstruction: a non-directory exists at the path (or an ancestor), or permission is denied.","triggerScenarios":"ensureDir callers (initialize, saveTasks, logActivity) invoked when the target path or an ancestor exists as a regular file, the filesystem is read-only, or the user lacks write permission on the parent directory.","commonSituations":"A file named like the directory (e.g. a file literally called '.taskmaster') blocks creation; running in a read-only container image or read-only mount; HOME misconfigured so the storage root resolves to an unwritable path; disk full (ENOSPC).","solutions":["Check the OS error in the message: if EEXIST/ENOTDIR, remove or rename the file occupying the path; if EACCES, fix parent-directory permissions.","Verify the storage root configuration (project path / HOME) points to a writable location.","If the filesystem is read-only (Docker/CI), mount a writable volume for the .taskmaster directory.","Free disk space if the error indicates ENOSPC."],"exampleFix":"// before\nls -la ~/ | grep .taskmaster   # -rw-r--r-- .taskmaster (a file)\n// after\nrm ~/ .taskmaster 2>/dev/null; rm ~/.taskmaster && mkdir ~/.taskmaster","handlingStrategy":"validation","validationCode":"import { stat } from 'fs/promises';\nimport path from 'path';\nexport async function canCreateDir(dirPath: string): Promise<boolean> {\n  try {\n    const s = await stat(dirPath);\n    return s.isDirectory(); // exists and IS a directory\n  } catch (err: any) {\n    if (err.code === 'ENOENT') {\n      const parent = path.dirname(dirPath);\n      try { await access(parent, constants.W_OK); return true; } catch { return false; }\n    }\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await fileOps.ensureDir(dirPath);\n} catch (err: any) {\n  if (err.message.startsWith('Failed to create directory')) {\n    console.error(`Check path ${dirPath}: a file may occupy it or perms deny write (${err.message})`);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Ensure no file exists at the same path as the intended directory (e.g. a literal file named .taskmaster).","Use a writable HOME/storage root; mount writable volumes in Docker/CI.","Run a startup check that the project path's parent is writable.","Watch for ENOSPC — keep adequate disk headroom."],"tags":["filesystem","directory","permissions","file-storage"],"backgroundTag":"mkdir-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}