Skip to content

Conversation

tomascupr
Copy link
Contributor

This PR updates Codex's default state directory to follow platform conventions while preserving backward compatibility.

Summary

  • Precedence:
    1. If CODEX_HOME is set and non‑empty, use it (canonicalized).
    2. Else, if legacy ~/.codex exists, continue using it.
    3. Else, default to dirs::config_dir()/codex (XDG on Linux; ~/Library/Application Support/codex on macOS; %AppData%\codex on Windows).
  • No change to the rest of the code: everything uses config.codex_home as before.

Why

  • Addresses Change the hardcoded $HOME/.codex path #4407: reduces $HOME clutter and aligns with XDG/AppData/Library conventions.
  • Keeps existing users stable via legacy fallback; new installs adopt the modern default seamlessly.

Details

  • Code: codex-rs/core/src/config.rs::find_codex_home() implements the new resolution order.
  • Tests: add unit tests covering env override, legacy fallback, and platform defaults.
  • Docs: replace hardcoded ~/.codex references with $CODEX_HOME and document platform defaults + legacy fallback.

Compatibility & Migration

  • Existing users with ~/.codex are unaffected (explicitly preferred).
  • New installs default under the platform config directory unless CODEX_HOME is set.

Verification

  • Ran just fmt.
  • Ran just fix -p codex-core.
  • Tests:
    • cargo test -p codex-core → PASS
    • cargo test --all-features (workspace) → PASS

Closes #4407.

…odex fallback; update docs and tests\n\n- Respects CODEX_HOME when set\n- Uses ~/.codex when it already exists (back-compat)\n- Otherwise falls back to dirs::config_dir()/codex on each platform\n- Updates docs to reference rather than ~/.codex\n- Adds unit tests for env override, legacy fallback, and platform default\n\nFixes openai#4407
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.

Change the hardcoded $HOME/.codex path
1 participant