{"record":{"id":"7d5cd57de9dd3d00","repo":"openai/codex","slug":"shell-snapshot-not-supported-yet-for-shell-type","errorCode":null,"errorMessage":"Shell snapshot not supported yet for {shell_type:?}","messagePattern":"Shell snapshot not supported yet for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"codex-rs/core/src/shell_snapshot.rs","lineNumber":207,"sourceCode":"\nimpl Drop for ShellSnapshotFile {\n    fn drop(&mut self) {\n        if let Err(err) = std::fs::remove_file(&self.path) {\n            tracing::warn!(\n                \"Failed to delete shell snapshot at {:?}: {err:?}\",\n                self.path\n            );\n        }\n    }\n}\n\nasync fn write_shell_snapshot(\n    shell_type: ShellType,\n    output_path: &AbsolutePathBuf,\n    cwd: &AbsolutePathBuf,\n) -> Result<()> {\n    if shell_type == ShellType::PowerShell || shell_type == ShellType::Cmd {\n        bail!(\"Shell snapshot not supported yet for {shell_type:?}\");\n    }\n    let shell =\n        get_shell(shell_type).with_context(|| format!(\"No available shell for {shell_type:?}\"))?;\n\n    let raw_snapshot = capture_snapshot(&shell, cwd).await?;\n    let snapshot = strip_snapshot_preamble(&raw_snapshot)?;\n\n    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}\"))?;","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/shell_snapshot.rs#L189-L225","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Disable the shell snapshot feature for Windows/PowerShell sessions (remove it from features config or scope it per-OS)","Override the user shell to a POSIX shell (bash/zsh via WSL on Windows) so snapshotting is supported","Treat the warning as benign if snapshots are optional for your flow — the session proceeds without one","Track upstream support for PowerShell/Cmd snapshots before re-enabling"],"exampleFix":"// before — snapshot enabled for every shell\nif config.features.enabled(Feature::ShellSnapshot) { snapshot = ShellSnapshot::new(...) }\n\n// after — only for POSIX shells\nlet posix = !matches!(default_shell.shell_type, ShellType::PowerShell | ShellType::Cmd);\nif config.features.enabled(Feature::ShellSnapshot) && posix { snapshot = ShellSnapshot::new(...) }","handlingStrategy":"type-guard","validationCode":"fn snapshot_supported(shell_type: ShellType) -> bool {\n    !matches!(shell_type, ShellType::PowerShell | ShellType::Cmd)\n}\n// only enable snapshots when snapshot_supported(session_shell.shell_type)","typeGuard":"fn is_posix_snapshot_shell(t: ShellType) -> bool {\n    matches!(t, ShellType::Zsh | ShellType::Bash | ShellType::Sh)\n}","tryCatchPattern":null,"preventionTips":["Scope the shell_snapshot feature flag to POSIX-shell sessions (per-OS or per-shell config)","On Windows, prefer disabling snapshots or running under WSL bash/zsh","Remember the failure is non-fatal: sessions continue without snapshots, so a warn-level alert is the right monitoring signal"],"tags":["rust","codex","shell-snapshot","powershell","cmd","unsupported-platform-feature"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}