openai/codex · warning · anyhow::Error

Shell snapshot not supported yet for {shell_type:?}

Error message

Shell snapshot not supported yet for {shell_type:?}

What it means

write_shell_snapshot refuses to snapshot PowerShell and Cmd shells up front: snapshot scripts that emit restorable shell state are only implemented for POSIX-family shells (zsh/bash/sh). The error is a deliberate capability guard, not a runtime fault; the caller (try_create) logs a warning and returns a "write_failed" failure reason, after which ShellSnapshot::build degrades to None — the session continues without a shell snapshot.

Source

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

impl Drop for ShellSnapshotFile {
    fn drop(&mut self) {
        if let Err(err) = std::fs::remove_file(&self.path) {
            tracing::warn!(
                "Failed to delete shell snapshot at {:?}: {err:?}",
                self.path
            );
        }
    }
}

async fn write_shell_snapshot(
    shell_type: ShellType,
    output_path: &AbsolutePathBuf,
    cwd: &AbsolutePathBuf,
) -> Result<()> {
    if shell_type == ShellType::PowerShell || shell_type == ShellType::Cmd {
        bail!("Shell snapshot not supported yet for {shell_type:?}");
    }
    let shell =
        get_shell(shell_type).with_context(|| format!("No available shell for {shell_type:?}"))?;

    let raw_snapshot = capture_snapshot(&shell, cwd).await?;
    let snapshot = strip_snapshot_preamble(&raw_snapshot)?;

    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}"))?;

View on GitHub (pinned to 339751715c)

Solutions

  1. Disable the shell snapshot feature for Windows/PowerShell sessions (remove it from features config or scope it per-OS)
  2. Override the user shell to a POSIX shell (bash/zsh via WSL on Windows) so snapshotting is supported
  3. Treat the warning as benign if snapshots are optional for your flow — the session proceeds without one
  4. Track upstream support for PowerShell/Cmd snapshots before re-enabling

Example fix

// before — snapshot enabled for every shell
if config.features.enabled(Feature::ShellSnapshot) { snapshot = ShellSnapshot::new(...) }

// after — only for POSIX shells
let posix = !matches!(default_shell.shell_type, ShellType::PowerShell | ShellType::Cmd);
if config.features.enabled(Feature::ShellSnapshot) && posix { snapshot = ShellSnapshot::new(...) }
Defensive patterns

Strategy: type-guard

Validate before calling

fn snapshot_supported(shell_type: ShellType) -> bool {
    !matches!(shell_type, ShellType::PowerShell | ShellType::Cmd)
}
// only enable snapshots when snapshot_supported(session_shell.shell_type)

Type guard

fn is_posix_snapshot_shell(t: ShellType) -> bool {
    matches!(t, ShellType::Zsh | ShellType::Bash | ShellType::Sh)
}

Prevention

When it happens

Trigger: ShellSnapshot feature enabled (Feature::ShellSnapshot) with the session's user shell resolving to ShellType::PowerShell or ShellType::Cmd — typical on Windows, or on any host where the user shell override points at powershell.exe/cmd.exe.

Common situations: Windows users with shell snapshots enabled; overriding the user shell to PowerShell on any OS; enabling the shell_snapshot feature flag globally (e.g. in an org-wide config) that then hits Windows machines.

Related errors


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