{"record":{"id":"ccf6871b1a04a0d9","repo":"eyaltoledano/claude-task-master","slug":"could-not-create-directory-for-pathtype-pare","errorCode":null,"errorMessage":"Could not create directory for ${pathType}: ${parentDir}. Error: ${error.message}","messagePattern":"Could not create directory for (.+?): (.+?)\\. Error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task-master.js","lineNumber":182,"sourceCode":"\t\tpathType,\n\t\toverride,\n\t\tdefaultPaths = [],\n\t\tbasePath = null,\n\t\tcreateParentDirs = false\n\t) => {\n\t\tif (typeof override === 'string') {\n\t\t\tconst resolvedPath = path.isAbsolute(override)\n\t\t\t\t? override\n\t\t\t\t: path.resolve(basePath || process.cwd(), override);\n\n\t\t\tif (createParentDirs) {\n\t\t\t\t// For output paths, create parent directory if it doesn't exist\n\t\t\t\tconst parentDir = path.dirname(resolvedPath);\n\t\t\t\tif (!fs.existsSync(parentDir)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfs.mkdirSync(parentDir, { recursive: true });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Could not create directory for ${pathType}: ${parentDir}. Error: ${error.message}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Original validation logic\n\t\t\t\tif (!fs.existsSync(resolvedPath)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${pathType} override path does not exist: ${resolvedPath}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn resolvedPath;\n\t\t}\n\n\t\tif (override === true) {\n\t\t\t// Required path - search defaults and fail if not found\n\t\t\tfor (const defaultPath of defaultPaths) {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/task-master.js#L164-L200","documentation":"resolvePath() creates the parent directory for output-type path overrides using fs.mkdirSync(recursive: true). If the OS-level mkdir fails (permissions, read-only filesystem, existing non-directory file at that path, EACCES/ENOSPC, etc.), the underlying error is wrapped in this message that includes the path type, the target directory, and the original error message. The thrown error is a wrapper — the cause is in the interpolated error.message.","triggerScenarios":"An output override path whose parent directory cannot be created: e.g. overrides.output = '/root/reports/tasks.json' without root permission; a regular file already exists at the parent path so mkdir fails with ENOTDIR/EEXIST; disk full or read-only mount.","commonSituations":"Running taskmaster in containers where the target volume is read-only; using home-relative paths as a different user (sudo vs user); typos making the path land in a restricted location like /system/... on Windows or /proc/... on Linux.","solutions":["Read the embedded Error: message at the end of the string (EACCES, ENOTDIR, ENOSPC) and address that cause.","Create the directory manually (mkdir -p <parentDir>) and confirm it succeeds; fix permissions with chmod/chown if needed.","Point the override at a writable location, e.g. a path under the project root or user home.","Check that nothing (a regular file) already occupies the parent directory path."],"exampleFix":"// before\n--output /var/restricted/out/tasks.json   // EACCES\n// after\nmkdir -p ./reports && task-master --output ./reports/tasks.json","handlingStrategy":"try-catch","validationCode":"const parentDir = path.dirname(path.resolve(outputPath));\nif (!fs.existsSync(parentDir)) {\n  fs.accessSync(path.dirname(parentDir), fs.constants.W_OK); // throws early with a clearer errno\n}\n","typeGuard":null,"tryCatchPattern":"try {\n  paths.output = tm.resolvePath({ output: userOutputPath });\n} catch (err) {\n  if (err.message.startsWith('Could not create directory')) {\n    console.error(err.message); // includes underlying fs error + parent dir\n    const fallback = path.join(process.cwd(), 'reports');\n    fs.mkdirSync(fallback, { recursive: true });\n    paths.output = fallback;\n  } else {\n    throw err;\n  }\n}","preventionTips":["Pre-create output directories in setup scripts (mkdir -p) before running taskmaster.","Point output overrides at project-relative or home-relative writable paths.","Avoid system paths (/var, /etc, /proc) as output destinations.","In containers, mount a writable volume and use it for outputs.","Parse the trailing fs error (EACCES/ENOSPC/ENOTDIR) from the message to diagnose quickly."],"tags":["filesystem","io","directory-creation","permissions"],"backgroundTag":"mkdir-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}