affaan-m/ECC · error · Error

No Codex rollout sessions found

Error message

No Codex rollout sessions found

What it means

resolveRolloutPath in the Codex adapter throws this when target 'latest' is requested but findLatestRollout(sessionsDir) finds no rollout files under the Codex sessions directory. There is no most-recent rollout to return.

Solutions

  1. Run Codex at least once to generate a rollout under the sessions directory.
  2. Verify resolveSessionsDir options/env (e.g. CODEX_HOME) point at the directory containing rollout .jsonl files.
  3. Pass an explicit rollout id or rollout file path instead of 'latest'.
  4. Run from the correct working directory if lookup is cwd-scoped.
  5. Check file permissions on the sessions directory (root-run CI can hide user dirs).

Example fix

// before
const { rolloutPath } = codexAdapter.resolveRolloutPath('latest'); // throws when empty
// after
const dir = path.join(os.homedir(), '.codex', 'sessions');
if (!fs.existsSync(dir) || fs.readdirSync(dir, { recursive: true }).filter(f => f.endsWith('.jsonl')).length === 0) {
  throw new Error('No Codex rollouts found; run `codex` first or set CODEX_HOME correctly');
}
Defensive patterns

Strategy: fallback

Validate before calling

const dir = resolveSessionsDir();
if (!fs.existsSync(dir) || findRolloutFiles(dir).length === 0) throw new Error('No Codex rollouts; run codex or fix sessions dir');

Type guard

function hasRollouts(dir) { return fs.existsSync(dir) && fs.readdirSync(dir, { recursive: true }).some(f => String(f).endsWith('.jsonl')); }

Try / catch

try { return adapter.resolveRolloutPath('latest'); } catch (e) { if (e.message === 'No Codex rollout sessions found') return null; throw e; }

Prevention

When it happens

Trigger: resolveRolloutPath called with explicitTarget === 'latest' while the resolved sessions dir (~/.codex/sessions or options-overridden dir) contains no rollout files or the dir does not exist.

Common situations: Codex never run on this machine/container; CODEX_HOME pointing at an empty directory; rollout files pruned by retention cleanup; running in a repo where Codex sessions are stored per-cwd and this project has none.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/1c809af25ee191cb. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/session-adapters/codex-worktree.js:110

  return files
    .map(filePath => ({ filePath, mtimeMs: fs.statSync(filePath).mtimeMs }))
    .sort((a, b) => b.mtimeMs - a.mtimeMs)[0].filePath;
}

function findRolloutById(sessionsDir, sessionId) {
  return listRolloutFiles(sessionsDir)
    .find(filePath => path.basename(filePath).includes(sessionId)) || null;
}

function resolveRolloutPath(target, cwd, options, context) {
  const explicitTarget = parseCodexTarget(target);
  const sessionsDir = resolveSessionsDir(options, context);

  if (explicitTarget) {
    if (explicitTarget === 'latest') {
      const latest = findLatestRollout(sessionsDir);
      if (!latest) {
        throw new Error('No Codex rollout sessions found');
      }

      return { rolloutPath: latest, sourceTarget: { type: 'codex-worktree', value: 'latest' } };
    }

    const absoluteExplicit = path.resolve(cwd, explicitTarget);
    if (fs.existsSync(absoluteExplicit) && isRolloutFile(absoluteExplicit)) {
      return { rolloutPath: absoluteExplicit, sourceTarget: { type: 'codex-rollout-file', value: absoluteExplicit } };
    }

    const byId = findRolloutById(sessionsDir, explicitTarget);
    if (byId) {
      return { rolloutPath: byId, sourceTarget: { type: 'codex-worktree', value: explicitTarget } };
    }

    throw new Error(`Codex rollout session not found: ${explicitTarget}`);
  }

View on GitHub (pinned to 8321021c54)