星苒鸭 (@xingranya)记录一下codex运行命令提示Exception setting "CursorPosition": "句柄无效。"的解决方案 中发帖

Codex CLI 在 PowerShell 中报错「Exception setting CursorPosition: 句柄无效」的修复记录
问题现象
在 Windows 使用 Codex CLI 时,几乎每条命令后都出现类似报错:
SetValueInvocationException:
Line |
3 | $RawUI.CursorPosition = @{X=0;Y=0}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception setting "CursorPosition": "句柄无效。"


根因结论
问题不在 Codex CLI 本身,而在 PowerShell Profile 初始化脚本:

Clear-Host 或某些终端美化逻辑会间接调用 RawUI.CursorPosition
在 Co...