{"record":{"id":"95b28991eae6bd8e","repo":"bmad-code-org/BMAD-METHOD","slug":"label-permission-denied-creating-directory","errorCode":null,"errorMessage":"${label}: permission denied creating directory: ${dirPath}","messagePattern":"(.+?): permission denied creating directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/installer/core/install-paths.js","lineNumber":117,"sourceCode":"  }\n  try {\n    await fs.access(filePath, fs.constants.R_OK);\n  } catch {\n    throw new Error(`${label} is not readable: ${filePath}`);\n  }\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":99,"sourceCodeEnd":133,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/tools/installer/core/install-paths.js#L99-L133","documentation":"Thrown by ensureWritableDir when fs.ensureDir (recursive mkdir) fails with EACCES — the OS denied permission to create the directory. Surfaces a specific permission cause instead of a generic mkdir error.","triggerScenarios":"InstallPaths.create() tries to create the project root or a _bmad subdirectory and mkdir is denied because the parent is not writable by the current user.","commonSituations":"Installing into a system directory, a parent owned by root while running as a normal user, or a read-only mount.","solutions":["Choose a writable target: pass `--directory` pointing at a location under your home dir.","Fix parent permissions: `chmod +w <parent>` or `chown` it to the current user.","Run with appropriate privileges only if installing into a system path is truly intended."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { access } from 'node:fs/promises';\nimport path from 'node:path';\nawait access(path.dirname(dirPath), fs.constants.W_OK); // parent writable?","typeGuard":null,"tryCatchPattern":"try {\n  await ensureWritableDir(dirPath, label);\n} catch (error) {\n  if (error.message.includes('permission denied creating directory')) { /* fix parent perms */ }\n  throw error;\n}","preventionTips":["Install into directories under your home folder.","Check parent-directory write permission before targeting system paths."],"tags":["filesystem","permissions","precondition","installer"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}