{"record":{"id":"3fc7841af5fedffe","repo":"openai/codex","slug":"createprocessw-in-cwd-failed","errorCode":null,"errorMessage":"CreateProcessW `{:?}` in cwd `{:?}` failed: {}","messagePattern":"CreateProcessW `(.+?)` in cwd `(.+?)` failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/utils/pty/src/win/psuedocon.rs","lineNumber":211,"sourceCode":"                ptr::null_mut(),\n                0,\n                EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT,\n                env_block.as_mut_ptr() as *mut _,\n                cwd.as_ref().map_or(ptr::null(), std::vec::Vec::as_ptr),\n                &mut si.StartupInfo,\n                &mut pi,\n            )\n        };\n        if res == 0 {\n            let err = IoError::last_os_error();\n            let msg = format!(\n                \"CreateProcessW `{:?}` in cwd `{:?}` failed: {}\",\n                cmd_os,\n                cwd.as_ref().map(|c| OsString::from_wide(c)),\n                err\n            );\n            log::error!(\"{msg}\");\n            bail!(\"{msg}\");\n        }\n\n        let _main_thread = unsafe { OwnedHandle::from_raw_handle(pi.hThread as _) };\n        let proc = unsafe { OwnedHandle::from_raw_handle(pi.hProcess as _) };\n\n        Ok(WinChild::new(proc, job))\n    }\n}\n\nfn resolve_current_directory(cmd: &CommandBuilder) -> Option<Vec<u16>> {\n    let home = cmd\n        .get_env(\"USERPROFILE\")\n        .and_then(|path| Path::new(path).is_dir().then(|| path.to_owned()));\n    let cwd = cmd\n        .get_cwd()\n        .and_then(|path| Path::new(path).is_dir().then(|| path.to_owned()));\n    let dir = cwd.or(home)?;\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/utils/pty/src/win/psuedocon.rs#L193-L229","documentation":"Fires in spawn_command when the Win32 CreateProcessW call returns 0, meaning the child process for the given command and working directory could not be spawned. The error captures the OS error (path not found, access denied, invalid executable, etc.) alongside the command and cwd for diagnosis.","triggerScenarios":"Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the executable path exists and is a valid PE binary the current user may execute","Verify the cwd exists and is accessible","Check the OS error code (e.g. ERROR_FILE_NOT_FOUND, ERROR_ACCESS_DENIED) for the precise cause","Validate the environment block is well-formed (CREATE_UNICODE_ENVIRONMENT requires a double-NUL-terminated wide block)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}