Yeachan-Heo/oh-my-codex · error · Error
agents-init target not found: ${requestedTarget}
Error message
agents-init target not found: ${requestedTarget} What it means
After confirming the agents-init target stays inside cwd, the code stats the resolved directory; if stat fails (ENOENT etc.) the target does not exist and this error is thrown. The target must exist beforehand — agents-init does not create the target directory.
Source
Thrown at src/cli/agents-init.ts:298
options: AgentsInitOptions = {},
): Promise<void> {
const dryRun = options.dryRun === true;
const force = options.force === true;
const verbose = options.verbose === true;
const cwd = process.cwd();
const requestedTarget = options.targetPath ?? ".";
const targetDir = resolve(cwd, requestedTarget);
const relativeTarget = relative(cwd, targetDir);
if (relativeTarget.startsWith("..")) {
throw new Error(
`agents-init target must stay inside the current working directory: ${requestedTarget}`,
);
}
const targetStat = await stat(targetDir).catch(() => null);
if (!targetStat)
throw new Error(`agents-init target not found: ${requestedTarget}`);
if (!targetStat.isDirectory())
throw new Error(
`agents-init target must be a directory: ${requestedTarget}`,
);
const summary = createEmptySummary();
const plannedDirs = await resolveTargetDirectories(targetDir);
const backupRoot = join(
cwd,
".omx",
"backups",
"agents-init",
new Date().toISOString().replaceAll(":", "-"),
);
const activeSession = await readSessionState(cwd);
const rootSessionGuardActive = Boolean(
activeSession && !isSessionStale(activeSession),
);View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Create the directory first: mkdir -p <target>
- Check for typos in the path argument
- Verify you are running from the expected working directory
Example fix
# before omx agents-init --target packages/new # after mkdir -p packages/new && omx agents-init --target packages/new
Defensive patterns
Strategy: validation
Validate before calling
import { statSync } from 'node:fs';
if (!statSync(targetDir, { throwIfNoEntry: false })) {
console.error(`target does not exist: ${targetDir}`);
process.exit(2);
} Prevention
- mkdir -p the target directory before scaffolding
- Verify cwd before running so relative targets resolve as expected
When it happens
Trigger: Passing --target subdir where subdir does not exist, or a typo'd path.
Common situations: Assuming agents-init mkdirs the target, stale scripts referencing deleted directories, or relative paths resolved against an unexpected cwd.
Related errors
- agents-init target must stay inside the current working dire
- agents-init target must be a directory: ${requestedTarget}
- Unknown agents-init option: ${arg}\n${AGENTS_INIT_USAGE}
- agents-init accepts at most one path argument.\n${AGENTS_INI
- agent not found: ${normalized}
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/82ffcc302893b22f.
Report an issue: GitHub.