Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): find the Codex CLI bundled with ChatGPT on macOS #14110

Closedmkantautas(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/14110/headopened View on GitHub

What Changed

When the Codex Binary path is the default codex and codex is not on PATH, the server on macOS uses the Codex CLI that the ChatGPT desktop app ships inside its bundle: /Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex, or Contents/Resources/codex in older builds. A Binary path set by hand, a codex on PATH, and other platforms keep their current behavior. The lookup runs once in CodexDriver when the instance is built, so the status check, sessions, text generation and updates all spawn the same binary.

Why

With only ChatGPT installed, Settings → Providers shows Codex as "Not found · Could not start Codex CLI (codex)":

Settings → Providers shows Codex as Not found with only ChatGPT installed

#10514 asked for this discovery; #11345 closed it with the Binary path hint and left discovery as a separate enhancement. A Binary path set by hand breaks when ChatGPT moves the CLI inside its bundle, which it has done once: #10514 found it at Contents/Resources/codex, and ChatGPT 26.924 ships it at Contents/Resources/codex-cli/bin/codex. I only had ChatGPT.app to confirm a layout, so the Codex desktop app is not in the list.

Checklist

  • This PR is small and focused
  • I explained what changed and why

Verified with vp test run src/provider/Drivers/CodexExecutable.test.ts (6 passed), vp lint and vp fmt --check on the three files, and the server typecheck. With codex off PATH and ChatGPT 26.924 installed, a server started from main fails the Codex probe with CodexAppServerSpawnError: Failed to spawn Codex App Server process for command: codex app-server; the same server from this branch passes it. CodexDriver.test.ts, ProviderRegistry.test.ts and ProviderInstanceRegistryLive.test.ts give the same results as on main: three CodexDriver update tests fail on macOS on both, because the temp directory resolves to /private/var.

Summary by CodeRabbit

  • Bug Fixes
    • On macOS, Codex can now use the CLI bundled with ChatGPT when the standard codex command isn’t available on PATH. If neither can be found, the standard command is retained.
    • Configured executable paths remain unchanged, and Linux behavior is unaffected. This helps Codex launch in more macOS setups without requiring changes to existing configuration.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change adds an automatic macOS fallback from the default codex command to executables bundled inside ChatGPT, affecting all Codex startup, probing, session, and generation paths for matching users. The stored setting is unchanged, but its default runtime behavior is materially different on that platform.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 4d585195-67cf-4906-8e9a-4b442acf9a13

      📥 Commits

      Reviewing files that changed from the base of the PR and between d15210cd3da79f9a1a495a6309d912d76362a046 and e9cbde6d7f007b52d194b779f5c1d5ea79ad0556.

      📒 Files selected for processing (3)
      • apps/server/src/provider/Drivers/CodexDriver.ts
      • apps/server/src/provider/Drivers/CodexExecutable.test.ts
      • apps/server/src/provider/Drivers/CodexExecutable.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The Codex driver now resolves its executable path using the instance environment. On macOS, the resolver checks codex on PATH, then checks two ChatGPT-bundled CLI paths. Configured paths and non-macOS defaults remain unchanged.

      Changes

      Codex executable path resolution

      Layer / File(s)Summary
      Resolve and apply the Codex binary path
      apps/server/src/provider/Drivers/CodexExecutable.ts, apps/server/src/provider/Drivers/CodexDriver.ts, apps/server/src/provider/Drivers/CodexExecutable.test.ts
      The resolver preserves configured paths and non-macOS defaults. On macOS, it checks codex on PATH, then checks two ChatGPT bundle paths in order. The driver uses the resolved path, and tests cover the selection and fallback cases.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Feature

      Merge Risk: ⚪ Minimal · up to e9cbd

      The macOS bundled-CLI lookup preserves the existing fallback when no executable is found. No identified issue blocks merging after normal checks.

      Security Architecture Review

      Security architecture risk: 🟡 Moderate · up to e9cbd

      On macOS, the server may now run a Codex executable from the ChatGPT application bundle without a manually configured path. The selection is limited to the default setting when Codex is absent from PATH, but the server does not verify the bundle’s identity before launching it. Whether another user could alter that bundle depends on installation permissions that remain unverified.

      Retained concerns

      • Medium · security · inferred: The default Codex setting can now launch a file at a fixed ChatGPT bundle path based on executability alone. If that path is writable by a less-trusted actor than the server, the new fallback would let that actor supply the process run by Codex operations; the required write access is not established.
      Security review details

      Security Blast Radius

      • inferred — If an attacker can replace a selected bundle executable, its code would run with the server-spawned Codex process’s authority and supplied environment. The evidence does not establish a tenant-wide scope, elevated privilege, or who can write the bundle.

      Security Findings and Attack Paths

      • inferred — The potential new attack path requires control of a qualifying fixed bundle path while the default codex command is absent from PATH. Executable-file checks alone would not distinguish a substituted file; attacker control of that location has not been demonstrated.

      Trust Boundaries and Controls

      • observed — Explicitly configured paths retain their prior precedence, PATH takes priority over the bundle, and bundle files must be executable. Arbitrary configured executable paths also predate this change; the new boundary is automatic selection of a bundle path for the default setting.

      Resilience and Maintainability Implications

      • inferred — Capturing one path per instance avoids divergent executable selection among the inspected consumers, but it fixes a pathname, not the file’s contents or provenance across later launches.

      Hardening Proposals

      • proposed — Establish the supported installation’s bundle ownership and provenance guarantees; if less-trusted actors can alter the bundle, require an appropriate authenticity or ownership check before automatic execution.
      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the main change: discovering the Codex CLI bundled with ChatGPT on macOS.
      Description check✅ PassedThe description includes the required What Changed, Why, and Checklist sections. It explains the behavior, scope, motivation, validation steps, and known test failures. The UI Changes section is corre…
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. Note

      This comment is posted by Julius' dot

      This silently selects a ChatGPT-bundled CLI when codex is absent from PATH. In #10514, Julius called this a separate product decision and specified user-selectable discovery, not a silent hard-coded fallback. The prior-approval rule requires agreement on that direction. Please obtain that approval or keep the existing Binary path workflow, then request reconsideration.

    5. juliusmarminge closed this

Sign in to join this conversation.