openai/codex · warning · anyhow::Error

Shell snapshotting is not yet supported for {shell_type:?}

Error message

Shell snapshotting is not yet supported for {shell_type:?}

What it means

capture_snapshot looks up a shell-native capture script via snapshot_script(shell_type) (codex-shell-command/src/shell_snapshot.rs). Only Zsh, Bash, Sh, and PowerShell have scripts; Cmd returns None (Command Prompt exposes no restorable state), so this anyhow! error fires. In the current code path write_shell_snapshot already rejects PowerShell and Cmd before reaching here, so this error is effectively the backstop for Cmd (and any future ShellType added without a snapshot script), or for direct capture_snapshot calls.

Source

Thrown at codex-rs/core/src/shell_snapshot.rs:233

    if let Some(parent) = output_path.parent() {
        let parent_display = parent.display();
        fs::create_dir_all(&parent)
            .await
            .with_context(|| format!("Failed to create snapshot parent {parent_display}"))?;
    }

    let snapshot_path = output_path.display();
    fs::write(output_path, snapshot)
        .await
        .with_context(|| format!("Failed to write snapshot to {snapshot_path}"))?;

    Ok(())
}

async fn capture_snapshot(shell: &Shell, cwd: &AbsolutePathBuf) -> Result<String> {
    let shell_type = shell.shell_type;
    let script = snapshot_script(shell_type)
        .ok_or_else(|| anyhow!("Shell snapshotting is not yet supported for {shell_type:?}"))?;
    run_shell_script(shell, &script, cwd).await
}

fn strip_snapshot_preamble(snapshot: &str) -> Result<String> {
    let marker = "# Snapshot file";
    let Some(start) = snapshot.find(marker) else {
        bail!("Snapshot output missing marker {marker}");
    };

    Ok(snapshot[start..].to_string())
}

async fn validate_snapshot(
    shell: &Shell,
    snapshot_path: &AbsolutePathBuf,
    cwd: &AbsolutePathBuf,
) -> Result<()> {
    let snapshot_path_display = snapshot_path.display();

View on GitHub (pinned to 339751715c)

Solutions

  1. Filter Cmd (and any script-less shell) before snapshotting, as write_shell_snapshot does for PowerShell/Cmd
  2. Add a snapshot_script arm for the shell type if it genuinely supports state capture
  3. Skip snapshots for Cmd sessions — snapshots are unsupported by design there (see the doc comment on snapshot_script)

Example fix

// before
let raw = capture_snapshot(&shell, &cwd).await; // Err for Cmd

// after — guard script-less shells first
if codex_shell_command::shell_snapshot::snapshot_script(shell.shell_type).is_none() {
    tracing::warn!("no snapshot script for {}", shell.name());
    return Ok(None);
}
let raw = capture_snapshot(&shell, &cwd).await;
Defensive patterns

Strategy: type-guard

Validate before calling

// Gate on script availability before attempting capture
use codex_shell_command::shell_snapshot::snapshot_script;
if snapshot_script(shell.shell_type).is_none() {
    tracing::warn!("no snapshot script for {}; skipping", shell.name());
    return Ok(None);
}

Type guard

fn has_snapshot_script(t: ShellType) -> bool {
    codex_shell_command::shell_snapshot::snapshot_script(t).is_some()
}

Prevention

When it happens

Trigger: Calling capture_snapshot (directly, or via write_shell_snapshot for a shell type not pre-filtered) with ShellType::Cmd — snapshot_script returns None and the error names the shell type.

Common situations: A new ShellType variant added to the enum without a snapshot_script arm; refactoring that removes the PowerShell/Cmd guard in write_shell_snapshot; tests or tooling invoking capture_snapshot with Cmd.

Related errors


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/97b3b283400f1606. Report an issue: GitHub.