can1357/oh-my-pi · error · SessionResolutionError

Session "${sessionArg}" belongs to a directory that no longe

Error message

Session "${sessionArg}" belongs to a directory that no longer exists (${sourceCwd}); run interactively to move it into the current project.

What it means

When resuming a session whose recorded project directory no longer exists on disk, omp offers to move the session into the current project. In non-interactive contexts no move prompt can be shown ('unavailable'), so moveMissingCwdSessionIfNeeded throws this SessionResolutionError telling the user to run interactively to perform the move.

Source

Thrown at packages/coding-agent/src/main.ts:709

	| { status: "not-needed" }
	| { status: "declined" }
	| { status: "moved"; manager: SessionManager };

async function moveMissingCwdSessionIfNeeded(
	sessionArg: string,
	session: SessionInfo,
	cwd: string,
	sessionDir: string | undefined,
	askToMoveSession: SessionPrompt,
): Promise<MissingCwdMoveResult> {
	const sourceCwd = session.cwd;
	if (!sourceCwd || fsSync.existsSync(sourceCwd)) {
		return { status: "not-needed" };
	}

	const movePromptResult = await askToMoveSession(session);
	if (movePromptResult === "unavailable") {
		throw new SessionResolutionError(
			`Session "${sessionArg}" belongs to a directory that no longer exists (${sourceCwd}); run interactively to move it into the current project.`,
		);
	}
	if (movePromptResult === "declined") {
		return { status: "declined" };
	}

	// Open anchored at the (now-missing) recorded cwd: `open` otherwise falls back
	// to the launch cwd, which would make the `moveTo` below a no-op whenever the
	// move target equals the current project dir. moveTo never chdirs, so the
	// stale cwd is only a relocation source, not a directory we enter.
	const manager = await SessionManager.open(session.path, sessionDir, undefined, { initialCwd: sourceCwd });
	await manager.moveTo(cwd, sessionDir);
	return { status: "moved", manager };
}

type ResumedProjectResult = { cwd: string; chdirFailed?: string };

View on GitHub (pinned to 9690622007)

Solutions

  1. Run omp interactively (in a TTY) and resume the session; accept the move prompt to relocate it into the current project.
  2. Recreate the original directory (mkdir -p <sourceCwd>) so the existence check passes, then resume.
  3. Hand-edit/move the session .jsonl into the current project's sessions directory.

Example fix

// non-interactive fails:
omp --resume <id> < /dev/null
// interactive instead:
omp --resume <id>   # answer 'yes' to the move prompt
Defensive patterns

Strategy: try-catch

Validate before calling

// check the session's recorded cwd before resuming non-interactively
import * as fsSync from "node:fs";
if (!fsSync.existsSync(recordedSessionCwd)) {
  console.error(`Session project dir ${recordedSessionCwd} is gone; resume interactively to move it.`);
}

Try / catch

try {
  await resumeSession(id);
} catch (err) {
  if (err.message.includes("belongs to a directory that no longer exists")) {
    // fall back to interactive prompt or recreate the dir
  }
}

Prevention

When it happens

Trigger: Resuming (or forking from) a session whose sourceCwd directory was deleted/renamed, while askToMoveSession returns 'unavailable' (no TTY / non-interactive mode).

Common situations: Project folder deleted or moved since the session was created; working inside a container/CI where the original path never existed; resuming over SSH without an interactive terminal.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/92fa97ba4c18ecb4. Report an issue: GitHub.