{"record":{"id":"de43578e38a7e857","repo":"bmad-code-org/BMAD-METHOD","slug":"label-cannot-create-directory-dirpath-e","errorCode":null,"errorMessage":"${label}: cannot create directory: ${dirPath} (${error.message})","messagePattern":"(.+?): cannot create directory: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/installer/core/install-paths.js","lineNumber":122,"sourceCode":"  }\n}\n\nasync function ensureWritableDir(dirPath, label) {\n  const stat = await fs.stat(dirPath).catch(() => null);\n  if (stat && !stat.isDirectory()) {\n    throw new Error(`${label} exists but is not a directory: ${dirPath}`);\n  }\n\n  try {\n    await fs.ensureDir(dirPath);\n  } catch (error) {\n    if (error.code === 'EACCES') {\n      throw new Error(`${label}: permission denied creating directory: ${dirPath}`);\n    }\n    if (error.code === 'ENOSPC') {\n      throw new Error(`${label}: no space left on device: ${dirPath}`);\n    }\n    throw new Error(`${label}: cannot create directory: ${dirPath} (${error.message})`);\n  }\n\n  try {\n    await fs.access(dirPath, fs.constants.R_OK | fs.constants.W_OK);\n  } catch {\n    throw new Error(`${label} is not writable: ${dirPath}`);\n  }\n}\n\nmodule.exports = { InstallPaths };\n","sourceCodeStart":104,"sourceCodeEnd":133,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/tools/installer/core/install-paths.js#L104-L133","documentation":"Catch-all thrown by ensureWritableDir when fs.ensureDir fails with an error code other than EACCES or ENOSPC. Includes the underlying error message so the root cause is visible.","triggerScenarios":"ensureDir raises an unexpected error during recursive mkdir, e.g. EROFS (read-only filesystem), EMFILE (too many open files), EIO, or a path that is too long.","commonSituations":"Installing onto a read-only filesystem, hitting OS resource limits, hardware/IO errors, or path-length limits on Windows.","solutions":["Read the parenthesized underlying message to identify the OS error code.","EROFS: remount read-write or pick a writable target.","EMFILE/ENFILE: raise ulimits or reduce concurrency.","EIO/hardware: check disk health; pick a different target."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await ensureWritableDir(dirPath, label);\n} catch (error) {\n  const m = error.message.match(/cannot create directory: .*\\((.*)\\)/);\n  if (m) { /* m[1] is the underlying OS error message; branch on it */ }\n  throw error;\n}","preventionTips":["Read the underlying error in parentheses to classify the OS failure.","For EROFS, relocate the target off the read-only filesystem."],"tags":["filesystem","precondition","installer","io-error"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}