Skip to content

fix(server): distinguish missing cwd from missing binary in codex version check#1961

Open
sachssem wants to merge 1 commit intopingdotgg:mainfrom
sachssem:fix/codex-enoent-cwd-error-message
Open

fix(server): distinguish missing cwd from missing binary in codex version check#1961
sachssem wants to merge 1 commit intopingdotgg:mainfrom
sachssem:fix/codex-enoent-cwd-error-message

Conversation

@sachssem
Copy link
Copy Markdown

@sachssem sachssem commented Apr 12, 2026

What Changed

assertSupportedCodexCliVersion now disambiguates ENOENT errors before blaming the binary. When spawnSync
fails with an ENOENT-class error, the handler checks whether the working directory is accessible. If the cwd is
the problem, the error message reports "Working directory '…' does not exist or is not accessible" instead
of "Codex CLI (codex) is not installed or not executable".

The check runs only in the error path (not as a preflight), so there is no TOCTOU race.

Single-file production change in codexAppServerManager.ts. One regression test added.

Why

assertSupportedCodexCliVersion passes the project directory as cwd to spawnSync. When that directory has
been deleted or moved, Node emits ENOENT. The existing error handler treats any ENOENT as a missing binary,
producing the misleading message "Codex CLI (codex) is not installed or not executable" — even when the CLI
is installed and on PATH.

This is confusing for users who see a "not installed" banner after simply moving a project folder.

Fixes #975, fixes #1932

Before / After

Before:
Screenshot 2026-04-12 at 18 15 13

After:
Screenshot 2026-04-12 at 18 12 44

Validation

  • bun fmt — clean
  • bun lint — clean
  • 38/38 codexAppServerManager tests pass (1 new)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes

Note

Low Risk
Low risk: change is limited to the Codex CLI version-check error path and adds a single regression test; main behavior only differs when spawnSync fails with ENOENT-like errors.

Overview
Improves assertSupportedCodexCliVersion to disambiguate ENOENT-style failures by checking cwd accessibility before reporting a missing/unexecutable Codex CLI binary, surfacing a clearer “working directory does not exist or is not accessible” error when appropriate.

Adds a regression test in codexAppServerManager.test.ts to ensure startSession emits session/startFailed and throws the new cwd-specific error when the provided cwd is missing.

Reviewed by Cursor Bugbot for commit 2d0d25b. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix assertSupportedCodexCliVersion to distinguish missing working directory from missing binary

When the Codex CLI version check fails with an ENOENT-like error, it was not clear whether the binary or the working directory was missing. Now, codexAppServerManager.ts checks cwd accessibility via fs.accessSync before concluding the binary is absent, throwing a specific 'Working directory ... does not exist or is not accessible.' error when the directory is the problem. A corresponding test case is added in codexAppServerManager.test.ts.

Macroscope summarized 2d0d25b.

…sion check

assertSupportedCodexCliVersion passes the project directory as cwd to
spawnSync. When that directory no longer exists, Node emits ENOENT
which the existing check misattributes to the Codex CLI binary being
missing, producing the misleading "Codex CLI (codex) is not installed
or not executable" error.

When an ENOENT-class error occurs, verify whether the cwd is
accessible before blaming the binary. This avoids a racy preflight
check while still producing a clear "Working directory '…' does not
exist or is not accessible" message for deleted or moved project
folders.

Adds a regression test that starts a session against a non-existent
cwd and asserts the corrected error message.

Fixes pingdotgg#975, fixes pingdotgg#1932
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dcf0f567-9182-42e8-8d65-2176c8d09640

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 12, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 12, 2026

Approvability

Verdict: Approved

Straightforward bug fix that improves error message accuracy when a working directory doesn't exist during codex version check. The change is limited to an error handling path, doesn't affect normal runtime behavior, and includes a test to verify the new behavior.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

1 participant