{"record":{"id":"614bcd8343498822","repo":"openai/codex","slug":"unknown-environment-shell-name","errorCode":null,"errorMessage":"unknown environment shell `{name}`","messagePattern":"unknown environment shell `(.+?)`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/core/src/shell.rs","lineNumber":69,"sourceCode":"\nimpl From<DetectedShell> for Shell {\n    fn from(detected: DetectedShell) -> Self {\n        Self {\n            shell_type: detected.shell_type,\n            shell_path: detected.shell_path,\n        }\n    }\n}\n\nimpl Shell {\n    pub(crate) fn from_environment_shell_info(shell_info: ShellInfo) -> anyhow::Result<Self> {\n        let shell_type = match shell_info.name.as_str() {\n            \"zsh\" => ShellType::Zsh,\n            \"bash\" => ShellType::Bash,\n            \"powershell\" => ShellType::PowerShell,\n            \"sh\" => ShellType::Sh,\n            \"cmd\" => ShellType::Cmd,\n            name => anyhow::bail!(\"unknown environment shell `{name}`\"),\n        };\n\n        Ok(Self {\n            shell_type,\n            shell_path: PathBuf::from(shell_info.path),\n        })\n    }\n}\n\n#[cfg(all(test, unix))]\nfn ultimate_fallback_shell() -> Shell {\n    codex_shell_command::shell_detect::ultimate_fallback_shell().into()\n}\n\npub fn get_shell_by_model_provided_path(shell_path: &PathBuf) -> Shell {\n    codex_shell_command::shell_detect::get_shell_by_model_provided_path(shell_path).into()\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/shell.rs#L51-L87","documentation":"Shell::from_environment_shell_info converts environment-provided shell info (a name + path pair, codex_exec_server::ShellInfo) into a Shell. It accepts an exact-match allowlist of lowercase names: zsh, bash, powershell, sh, cmd. Any other name string bails with this error. It is a strict value-validation failure on the wire/environment data, not a lookup of the binary itself.","triggerScenarios":"Calling from_environment_shell_info with ShellInfo.name set to anything outside {zsh, bash, powershell, sh, cmd} — e.g. \"fish\", \"nu\", \"pwsh\", \"dash\", \"tcsh\", \"xonsh\", or a capitalized variant like \"Zsh\".","commonSituations":"User's login shell (via SHELL or exec-server environment reporting) is fish, nushell, or another non-listed shell; PowerShell Core reported as \"pwsh\" instead of \"powershell\"; a custom exec-server or harness sending its own shell naming scheme; case-sensitive mismatch after an environment-reporting change.","solutions":["Set the environment to a supported shell: export SHELL=/bin/bash (or /bin/zsh), or chsh -s /bin/zsh, then restart the session","Normalize the name before conversion: map \"pwsh\"→\"powershell\" and lowercase the string at the source that builds ShellInfo","If you control the exec server, only report one of the five supported names","File/support adding the shell to the allowlist in shell.rs if it is a legitimate new shell type"],"exampleFix":"// before — environment reports PowerShell Core as \"pwsh\"\nlet shell = Shell::from_environment_shell_info(ShellInfo { name: \"pwsh\".into(), path: pwsh_path })?; // unknown environment shell `pwsh`\n\n// after — normalize to the accepted name\nlet name = match info.name.as_str() { \"pwsh\" | \"powershell\" => \"powershell\", n => n }.to_string();\nlet shell = Shell::from_environment_shell_info(ShellInfo { name, path: pwsh_path })?;\n// (or simply: export SHELL=/bin/zsh in the user environment)","handlingStrategy":"type-guard","validationCode":"const SUPPORTED: &[&str] = &[\"zsh\", \"bash\", \"powershell\", \"sh\", \"cmd\"];\nif !SUPPORTED.contains(&shell_info.name.as_str()) {\n    return normalise_or_reject(shell_info); // map \"pwsh\"→\"powershell\", else fall back to SHELL env\n}","typeGuard":"fn is_supported_shell_name(name: &str) -> bool {\n    matches!(name, \"zsh\" | \"bash\" | \"powershell\" | \"sh\" | \"cmd\")\n}","tryCatchPattern":"match Shell::from_environment_shell_info(info.clone()) {\n    Ok(shell) => shell,\n    Err(e) if e.to_string().contains(\"unknown environment shell\") => {\n        Shell::from_environment_shell_info(normalize_shell_name(info))?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Set SHELL to a supported shell (zsh/bash) in automation and container images","Normalize shell names (lowercase; pwsh→powershell) where you produce ShellInfo","Add unit tests over the five accepted names plus one rejected name when you touch shell plumbing"],"tags":["rust","codex","shell","unsupported-value","environment-validation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}