Skip to content

fix(codex): create CODEX_HOME before pinning it in the app-server env#39

Merged
MarinRzv merged 1 commit into
mainfrom
fix/codex-home-mkdir
Jul 22, 2026
Merged

fix(codex): create CODEX_HOME before pinning it in the app-server env#39
MarinRzv merged 1 commit into
mainfrom
fix/codex-home-mkdir

Conversation

@dmorosanu

Copy link
Copy Markdown
Contributor

Problem

Every codex run with mocks configured on POSIX fails at startup since #26:

Failed to initialize Codex client: Codex process closed stdout. stderr_tail=WARNING: proceeding, even though we could not create PATH aliases: CODEX_HOME points to "/root/.codex", but that path does not exist
Error: CODEX_HOME points to "/root/.codex", but that path does not exist

#26 pins CODEX_HOME in the app-server env (so codex state does not follow the redirected login-shell HOME). The codex binary treats an explicitly set CODEX_HOME strictly: it hard-errors when the path does not exist, whereas with the env var unset it materializes the ~/.codex default itself. On runners that auth via CODEX_API_KEY (never ran codex login), ~/.codex does not exist, so the app-server dies at startup. Dev machines have ~/.codex, unit tests pointed CODEX_HOME at existing tmp dirs, and Windows never enters the login-shell path - which is why nothing caught it.

Fix

Create the resolved dir (mkdir(parents=True, exist_ok=True)) before pinning it - mirrors the binary's own default-dir behavior, idempotent across start() retries.

Validation

  • New regression test test_build_codex_env_creates_missing_codex_home (fails on main, passes here).
  • Reproduced against the bundled codex-cli 0.144.4 binary: codex app-server with CODEX_HOME pointing at a nonexistent dir exits 1 with the exact error above; with the dir pre-created it starts cleanly.
  • Full suite: 3342 passed (2 pre-existing Windows symlink-privilege failures in test_sandbox.py, also failing on main); ruff format/check and pyright clean.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Claude finished @dmorosanu's task in 1m 23s —— View job


Code Review in Progress

Todo List:

  • Read .github/code_review.md for review guidelines
  • Read CLAUDE.md for project conventions
  • Analyze the full diff with git diff origin/main...HEAD
  • Read full context of changed files
  • Review src/coder_eval/agents/codex_agent.py changes
  • Review tests/test_codex_agent.py changes
  • Check cross-file consistency
  • Analyze what's missing
  • Provide comprehensive review feedback

@MarinRzv
MarinRzv merged commit 8d98b91 into main Jul 22, 2026
14 of 15 checks passed
@MarinRzv
MarinRzv deleted the fix/codex-home-mkdir branch July 22, 2026 10:59
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.

2 participants