{"record":{"id":"a1f35cc08c4da0f9","repo":"bmad-code-org/BMAD-METHOD","slug":"label-is-not-a-file-filepath","errorCode":null,"errorMessage":"${label} is not a file: ${filePath}","messagePattern":"(.+?) is not a file: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/installer/core/install-paths.js","lineNumber":98,"sourceCode":"    throw new Error(`${label} does not exist: ${dirPath}`);\n  }\n  if (!stat.isDirectory()) {\n    throw new Error(`${label} is not a directory: ${dirPath}`);\n  }\n  try {\n    await fs.access(dirPath, fs.constants.R_OK);\n  } catch {\n    throw new Error(`${label} is not readable: ${dirPath}`);\n  }\n}\n\nasync function assertReadableFile(filePath, label) {\n  const stat = await fs.stat(filePath).catch(() => null);\n  if (!stat) {\n    throw new Error(`${label} does not exist: ${filePath}`);\n  }\n  if (!stat.isFile()) {\n    throw new Error(`${label} is not a file: ${filePath}`);\n  }\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') {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/tools/installer/core/install-paths.js#L80-L116","documentation":"Thrown by assertReadableFile when the path exists but stat.isFile() is false — a directory or special file sits where a regular file is required. Lets the user distinguish a type mismatch from a missing/unreadable file.","triggerScenarios":"assertReadableFile is called on a path (e.g. the package.json path) that resolves to a directory instead of a regular file.","commonSituations":"A directory was created with the same name as an expected file (e.g. someone ran `mkdir package.json`), or a symlink points at a directory where a file was expected.","solutions":["Inspect the node: `ls -la <filePath>`.","Remove the directory/symlink and restore the expected regular file (e.g. reinstall the package).","Audit any tooling that may have created a directory in place of the file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const stat = await fs.stat(filePath).catch(() => null);\nif (stat && !stat.isFile()) {\n  // warn: a directory occupies the expected file path\n}","typeGuard":null,"tryCatchPattern":"try {\n  await assertReadableFile(filePath, label);\n} catch (error) {\n  if (error.message.includes('is not a file')) { /* wrong type */ }\n  throw error;\n}","preventionTips":["Never create directories with names of expected files.","Reinstall the package to restore correct file/directory layout."],"tags":["filesystem","precondition","installer"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}