affaan-m/ECC · error · Error
Expected a directory: ${dirPath}
Error message
Expected a directory: ${dirPath} What it means
Thrown by ensureDirectory() in scripts/gemini-adapt-agents.js when the path exists (passes existsSync) but is not a directory — fs.statSync().isDirectory() returns false. This catches cases where the path points to a file, symlink to a file, or other non-directory filesystem entry.
Source
Thrown at scripts/gemini-adapt-agents.js:53
const positional = argv.filter(arg => !arg.startsWith('-'));
if (positional.length > 1) {
throw new Error('Expected at most one agents directory argument');
}
return {
help: false,
agentsDir: path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents')),
};
}
function ensureDirectory(dirPath) {
if (!fs.existsSync(dirPath)) {
throw new Error(`Agents directory not found: ${dirPath}`);
}
if (!fs.statSync(dirPath).isDirectory()) {
throw new Error(`Expected a directory: ${dirPath}`);
}
}
function parseToolList(line) {
const match = line.match(/^\s*tools\s*:\s*(.*)$/);
if (!match) {
return null;
}
return normalizeAgentTools(match[1]);
}
function adaptToolName(toolName) {
const mapped = TOOL_NAME_MAP.get(toolName);
if (mapped) {
return mapped;
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Ensure the path points to a directory, not a file.
- If you passed an agent file path, use its parent directory instead.
- Check with `ls -la <path>` to confirm it is a directory.
- Remove or rename the conflicting file if it was created by mistake.
Example fix
// before node scripts/gemini-adapt-agents.js .gemini/agents/my-agent.md // after node scripts/gemini-adapt-agents.js .gemini/agents
Defensive patterns
Strategy: validation
Validate before calling
const stat = fs.statSync(dirPath);
if (!stat.isDirectory()) {
console.error(`Path is not a directory: ${dirPath}. Use the parent directory, not a file.`);
process.exit(1);
} Type guard
function isDirectory(p) {
try { return fs.statSync(p).isDirectory(); } catch { return false; }
} Prevention
- Always pass a directory path, not an individual file path.
- Use `ls -ld <path>` to verify the entry is a directory before running.
- Avoid passing symlinks unless you have verified they resolve to a directory.
When it happens
Trigger: Passing a path that resolves to a regular file (e.g. `node scripts/gemini-adapt-agents.js .gemini/agents/some-agent.md`) instead of the parent directory, or pointing at a named pipe/socket.
Common situations: User passes an individual agent file path instead of the directory, or a stale symlink points to a file. Also common when the default `.gemini/agents` is accidentally a file created by a misconfigured tool.
Related errors
- Agents directory not found: ${dirPath}
- Expected at most one agents directory argument
- --config-dir must exist and contain a regular sixtytwo.yaml
- ${EXECUTABLE_OVERRIDE} does not point to a readable local It
- Missing value for --write
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/cbc6c41ed96bcfea.
Report an issue: GitHub.