Skip to content

Commit 1b626e4

Browse files
committed
fix: detect Windows Codex updates that bypass .cmd shim via PATHEXT
On Windows, .EXE has higher PATHEXT priority than .CMD. When a Codex update installs a new codex.exe alongside the existing codex.cmd shim, the shim is bypassed. Now installCodexShim() detects the reappeared originalPath .exe, backs up the new binary, and refreshes the wrapper. Also corrects README auto-repair wording in all 3 languages.
1 parent b087075 commit 1b626e4

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

README.ko.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ opencodex에는 프록시를 자동 시작하는 두 가지 방법이 있습니
144144
| **방식** | OS 서비스 관리자 (launchd / systemd / schtasks) | `codex` 바이너리를 래퍼 스크립트로 교체 |
145145
| **시점** | 로그인 후 항상 실행 | 온디맨드 — `codex` 실행 시에만 시작 |
146146
| **재시작** | 크래시 시 자동 재시작 | `codex` 호출마다 한 번 시작 |
147-
| **Codex 업데이트** | 영향 없음 | 자동 복구; 새 바이너리를 백업 |
147+
| **Codex 업데이트** | 영향 없음 | `ocx codex-shim install` 또는 `ocx update` 시 복구 |
148148
| **제거** | `ocx service uninstall` | `ocx codex-shim uninstall` |
149149

150150
항상 프록시를 켜두려면 **service** (개발 머신 권장), 가볍게 온디맨드로 쓰려면 **shim**을 사용하세요.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ opencodex has two ways to auto-start the proxy:
166166
| **How** | OS service manager (launchd / systemd / schtasks) | Replaces the `codex` binary with a wrapper script |
167167
| **When** | Always running after login | On-demand — starts only when `codex` is launched |
168168
| **Restart** | Auto-restarts on crash | Starts once per `codex` invocation |
169-
| **Codex updates** | Unaffected | Shim auto-repairs; backs up the new binary |
169+
| **Codex updates** | Unaffected | Repairs on next `ocx codex-shim install` or `ocx update` |
170170
| **Remove** | `ocx service uninstall` | `ocx codex-shim uninstall` |
171171

172172
Use the **service** for always-on proxy (recommended for development machines). Use the **shim** for

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ opencodex 提供两种自动启动代理的方式:
141141
| **方式** | OS 服务管理器(launchd / systemd / schtasks) |`codex` 二进制替换为包装脚本 |
142142
| **时机** | 登录后始终运行 | 按需 — 仅在运行 `codex` 时启动 |
143143
| **重启** | 崩溃后自动重启 | 每次调用 `codex` 时启动一次 |
144-
| **Codex 更新** | 不受影响 | 自动修复;备份新版二进制 |
144+
| **Codex 更新** | 不受影响 | 下次运行 `ocx codex-shim install``ocx update` 时修复 |
145145
| **移除** | `ocx service uninstall` | `ocx codex-shim uninstall` |
146146

147147
如需常驻代理,使用 **service**(推荐开发环境)。轻量按需启动使用 **shim**

src/codex-shim.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ function writeShim(wrapperPath: string, realCodexPath: string): void {
115115
export function installCodexShim(): { installed: boolean; message: string } {
116116
const existing = readState();
117117
if (existing && existsSync(existing.wrapperPath) && existsSync(existing.backupPath) && isShim(existing.wrapperPath)) {
118+
if (process.platform === "win32" && existing.originalPath && existsSync(existing.originalPath)) {
119+
renameSync(existing.originalPath, existing.backupPath);
120+
writeShim(existing.wrapperPath, existing.backupPath);
121+
writeState({ ...existing, platform: process.platform });
122+
return {
123+
installed: true,
124+
message: `Codex update detected. Backed up new binary and refreshed shim at ${existing.wrapperPath}.`,
125+
};
126+
}
118127
return { installed: false, message: `Codex autostart shim already installed at ${existing.wrapperPath}.` };
119128
}
120129
if (existing && existsSync(existing.backupPath) && (!existsSync(existing.wrapperPath) || !isShim(existing.wrapperPath))) {

0 commit comments

Comments
 (0)