一次离奇的「codex 命令丢失」排查与修复之旅
📅 2026/7/14 22:09:11
👁️ 阅读次数
📝 编程学习
从
'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/11 |
| Shell | CMD(命令提示符) |
| 包管理工具 | npm、Git、Python |
| 关键目录 | C:\Users\Administrator\bin |
| 配置文件 | C:\Users\Administrator\.codex\config.toml |
三、排查过程
第一步:检查 PATH 环境变量
cmd
echo %PATH%发现 PATH 中包含C:\Users\Administrator\bin,但没有明确的codex相关路径。
第二步:检查codex命令是否存在
cmd
where codex返回:
text
INFO: Could not find files for the given pattern(s).确认系统已无法识别codex命令。
第三步:检查用户自定义 bin 目录
cmd
dir C:\Users\Administrator\bin
编程学习
技术分享
实战经验