{"record":{"id":"cbc6c41ed96bcfea","repo":"affaan-m/ECC","slug":"expected-a-directory-dirpath","errorCode":null,"errorMessage":"Expected a directory: ${dirPath}","messagePattern":"Expected a directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/gemini-adapt-agents.js","lineNumber":53,"sourceCode":"\n  const positional = argv.filter(arg => !arg.startsWith('-'));\n  if (positional.length > 1) {\n    throw new Error('Expected at most one agents directory argument');\n  }\n\n  return {\n    help: false,\n    agentsDir: path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents')),\n  };\n}\n\nfunction ensureDirectory(dirPath) {\n  if (!fs.existsSync(dirPath)) {\n    throw new Error(`Agents directory not found: ${dirPath}`);\n  }\n\n  if (!fs.statSync(dirPath).isDirectory()) {\n    throw new Error(`Expected a directory: ${dirPath}`);\n  }\n}\n\nfunction parseToolList(line) {\n  const match = line.match(/^\\s*tools\\s*:\\s*(.*)$/);\n  if (!match) {\n    return null;\n  }\n\n  return normalizeAgentTools(match[1]);\n}\n\nfunction adaptToolName(toolName) {\n  const mapped = TOOL_NAME_MAP.get(toolName);\n  if (mapped) {\n    return mapped;\n  }\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/gemini-adapt-agents.js#L35-L71","documentation":"ensureDirectory() validates that the given path is a directory via fs.statSync(dirPath).isDirectory(). If the path exists but is a regular file (or symlink to one), it throws 'Expected a directory: <dirPath>'.","triggerScenarios":"Passing a file path (e.g. .gemini/agents.md or a README) where the agents directory is expected, or a symlink pointing to a file instead of a directory.","commonSituations":"Pointing the script at a config file instead of the folder, a repo migration that replaced the directory with a file, or autocomplete selecting a file rather than the directory.","solutions":["Verify with `ls -la <path>` that the target is a directory, not a file.","Point the script at the actual agents directory (e.g. `.gemini/agents`).","Remove or rename the file occupying the expected directory path and create the directory: `mkdir .gemini/agents`.","If it is a broken symlink, fix or remove it with `rm <symlink>` and recreate the directory."],"exampleFix":"// before\n$ node scripts/gemini-adapt-agents.js .gemini/AGENTS.md\nError: Expected a directory: .gemini/AGENTS.md\n// after\n$ node scripts/gemini-adapt-agents.js .gemini/agents","handlingStrategy":"type-guard","validationCode":"const fs = require('fs');\nconst p = process.argv[2] || '.gemini/agents';\nif (fs.existsSync(p) && !fs.statSync(p).isDirectory()) {\n  console.error(`${p} is a file, not a directory`);\n  process.exit(1);\n}","typeGuard":"const isDirectory = (p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } };","tryCatchPattern":"try {\n  adaptAgents(argv);\n} catch (err) {\n  if (/^Expected a directory:/.test(err.message)) {\n    console.error(`${err.message}\\nPass the agents folder (e.g. .gemini/agents), not a file.`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Point the script at a folder, never a file like AGENTS.md.","Use tab-completion on directories or append a trailing slash to force directory completion.","Check `ls -la` for symlinks that resolve to files.","After repo restructuring, confirm the directory still exists as a directory."],"tags":["cli","path-is-not-a-directory","type-mismatch"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}