{"record":{"id":"97b3b283400f1606","repo":"openai/codex","slug":"shell-snapshotting-is-not-yet-supported-for-shell","errorCode":null,"errorMessage":"Shell snapshotting is not yet supported for {shell_type:?}","messagePattern":"Shell snapshotting is not yet supported for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"codex-rs/core/src/shell_snapshot.rs","lineNumber":233,"sourceCode":"    if let Some(parent) = output_path.parent() {\n        let parent_display = parent.display();\n        fs::create_dir_all(&parent)\n            .await\n            .with_context(|| format!(\"Failed to create snapshot parent {parent_display}\"))?;\n    }\n\n    let snapshot_path = output_path.display();\n    fs::write(output_path, snapshot)\n        .await\n        .with_context(|| format!(\"Failed to write snapshot to {snapshot_path}\"))?;\n\n    Ok(())\n}\n\nasync fn capture_snapshot(shell: &Shell, cwd: &AbsolutePathBuf) -> Result<String> {\n    let shell_type = shell.shell_type;\n    let script = snapshot_script(shell_type)\n        .ok_or_else(|| anyhow!(\"Shell snapshotting is not yet supported for {shell_type:?}\"))?;\n    run_shell_script(shell, &script, cwd).await\n}\n\nfn strip_snapshot_preamble(snapshot: &str) -> Result<String> {\n    let marker = \"# Snapshot file\";\n    let Some(start) = snapshot.find(marker) else {\n        bail!(\"Snapshot output missing marker {marker}\");\n    };\n\n    Ok(snapshot[start..].to_string())\n}\n\nasync fn validate_snapshot(\n    shell: &Shell,\n    snapshot_path: &AbsolutePathBuf,\n    cwd: &AbsolutePathBuf,\n) -> Result<()> {\n    let snapshot_path_display = snapshot_path.display();","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/shell_snapshot.rs#L215-L251","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Filter Cmd (and any script-less shell) before snapshotting, as write_shell_snapshot does for PowerShell/Cmd","Add a snapshot_script arm for the shell type if it genuinely supports state capture","Skip snapshots for Cmd sessions — snapshots are unsupported by design there (see the doc comment on snapshot_script)"],"exampleFix":"// before\nlet raw = capture_snapshot(&shell, &cwd).await; // Err for Cmd\n\n// after — guard script-less shells first\nif codex_shell_command::shell_snapshot::snapshot_script(shell.shell_type).is_none() {\n    tracing::warn!(\"no snapshot script for {}\", shell.name());\n    return Ok(None);\n}\nlet raw = capture_snapshot(&shell, &cwd).await;","handlingStrategy":"type-guard","validationCode":"// Gate on script availability before attempting capture\nuse codex_shell_command::shell_snapshot::snapshot_script;\nif snapshot_script(shell.shell_type).is_none() {\n    tracing::warn!(\"no snapshot script for {}; skipping\", shell.name());\n    return Ok(None);\n}","typeGuard":"fn has_snapshot_script(t: ShellType) -> bool {\n    codex_shell_command::shell_snapshot::snapshot_script(t).is_some()\n}","tryCatchPattern":null,"preventionTips":["When adding a ShellType variant, add its snapshot_script arm in the same change","Keep the PowerShell/Cmd guard in write_shell_snapshot in sync with snapshot_script coverage","Test snapshot creation per shell type in CI so unsupported shells fail early and explicitly"],"tags":["rust","codex","shell-snapshot","cmd","feature-gap"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}