Skip to content

fix(codex): don't clobber codex.js — rm npm symlink before writing the Bedrock wrapper#200

Merged
wdvr merged 1 commit into
mainfrom
fix/codex-symlink-clobber
Jun 2, 2026
Merged

fix(codex): don't clobber codex.js — rm npm symlink before writing the Bedrock wrapper#200
wdvr merged 1 commit into
mainfrom
fix/codex-symlink-clobber

Conversation

@wdvr
Copy link
Copy Markdown
Owner

@wdvr wdvr commented Jun 2, 2026

Symptom

codex hangs on launch (appears to ask for ChatGPT login / spins forever) on pods built from the #198 image.

Root cause

The Bedrock wrapper is installed with:

echo '<b64>' | base64 -d > /usr/local/bin/codex

But npm install -g --prefix /usr/local @openai/codex leaves /usr/local/bin/codex as a symlink../lib/node_modules/@openai/codex/bin/codex.js. The redirect follows the symlink and overwrites codex.js itself with the wrapper. The wrapper does exec "$REAL" where REAL=.../codex.js — which is now the wrapper — so it execs itself forever (infinite execve recursion) → hang.

Proof: node codex.js --version errors with SyntaxError: Invalid or unexpected token on the line # Codex wired to GPT-5.5... — i.e. node is parsing the bash wrapper as JS, because codex.js is the wrapper.

Fix

rm -f /usr/local/bin/codex before the redirect, so a real file is written at the bin path and codex.js stays the genuine launcher.

Verification (live pod)

  • Token mint (aws_bedrock_token_generator): OK (2208-char bedrock-api-key-…)
  • POST /openai/v1/responses (non-stream): 200, "Hi!", 0.49s
  • SSE streaming: full event sequence, deltas, done
  • After applying the fix recipe (reinstall codex.js + wrapper as a real file): codex exec as dev returns "hi" via provider=bedrock model=openai.gpt-5.5, reasoning effort high.

So the API/auth/network were always healthy — the hang was purely the recursion.

Deploy

Needs the image rebuild (tofu apply prod). Existing pods on the bad image can be repaired in-place: reinstall codex (npm install -g --prefix /usr/local @openai/codex --force) then rm -f /usr/local/bin/codex + reinstate the wrapper as a real file.

…g the wrapper

The Bedrock wrapper was installed with 'base64 -d > /usr/local/bin/codex', but
'npm install -g' leaves that path as a SYMLINK to the real launcher
(.../node_modules/@openai/codex/bin/codex.js). The redirect followed the symlink
and overwrote codex.js with the wrapper itself, so the wrapper's exec "$REAL"
(REAL=codex.js) re-exec'd the wrapper -> infinite exec recursion -> codex hangs
on every launch (asks-for-login / spins forever).

Fix: 'rm -f /usr/local/bin/codex' before the redirect so a real file is created
at the bin path and codex.js stays the genuine launcher.

Verified on a live pod: with codex.js restored + wrapper as a real file, 'codex
exec' as dev returns 'hi' via bedrock/openai.gpt-5.5 (effort high). The token
mint, the responses endpoint, and SSE streaming were all confirmed healthy — the
hang was purely the recursion.
@wdvr wdvr merged commit aca431f into main Jun 2, 2026
3 checks passed
@wdvr wdvr deleted the fix/codex-symlink-clobber branch June 2, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant