affaan-m/ECC · error · Error
Agents directory not found: ${dirPath}
Error message
Agents directory not found: ${dirPath} What it means
Thrown by ensureDirectory() in scripts/gemini-adapt-agents.js when the resolved agents directory path does not exist on the filesystem (fs.existsSync returns false). This is a preflight check before the script attempts to read and rewrite agent files in that directory.
Source
Thrown at scripts/gemini-adapt-agents.js:49
function parseArgs(argv) {
if (argv.includes('--help') || argv.includes('-h')) {
return { help: true };
}
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);View on GitHub (pinned to 01e15490f0)
Solutions
- Create the directory first: `mkdir -p .gemini/agents` and populate it with agent files.
- Verify the path you passed exists: `ls <path>`.
- Run the script from the project root where `.gemini/agents` is expected.
- If migrating from another harness, copy agent files into the directory first.
Example fix
// before node scripts/gemini-adapt-agents.js ./wrong-path // after mkdir -p .gemini/agents && node scripts/gemini-adapt-agents.js .gemini/agents
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const target = path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents'));
if (!fs.existsSync(target)) {
console.error(`Creating agents directory: ${target}`);
fs.mkdirSync(target, { recursive: true });
} Type guard
function directoryExists(p) {
try { return fs.statSync(p).isDirectory(); } catch { return false; }
} Prevention
- Run `mkdir -p .gemini/agents` before invoking the script.
- Verify the working directory is correct before relying on defaults.
- In CI, add a pre-step that scaffolds the expected directory.
When it happens
Trigger: Running the script with a directory path that does not exist, or running without arguments in a project that has not yet created the `.gemini/agents` directory.
Common situations: First-time use of the Gemini adapter before the `.gemini/agents` directory has been scaffolded, passing a typo'd path, or running from the wrong working directory so the default relative path resolves to a non-existent location.
Related errors
- Expected a directory: ${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/fcb21c127839f998.
Report an issue: GitHub.