一次离奇的「codex 命令丢失」排查与修复之旅 从'codex' is not recognized到成功运行 OpenAI Codex CLI,记录一次 Windows 环境下的完整排障过程一、问题现象在某天正常使用电脑时,突然发现 CMD 中无法执行codex命令:cmd'codex' is not recognized as an internal or external command, operable program or batch file.而前一秒还能正常使用,中间只经历了一次网络闪断。二、环境信息项目信息操作系统Windows 10/11ShellCMD(命令提示符)包管理工具npm、Git、Python关键目录C:\Users\Administrator\bin配置文件C:\Users\Administrator\.codex\config.toml三、排查过程第一步:检查 PATH 环境变量cmdecho %PATH%发现 PATH 中包含C:\Users\Administrator\bin,但没有明确的codex相关路径。第二步:检查codex命令是否存在cmdwhere codex返回:textINFO: Could not find files for the given pattern(s).确认系统已无法识别codex命令。第三步:检查用户自定义 bin 目录cmddir C:\Users\Administrator\bin