fix: resolve default Codex home from USERPROFILE on Windows#21
Merged
Conversation
When neither --codex-home nor CODEX_HOME is set, the default home base was taken solely from $HOME. On Windows a process that injects HOME (e.g. an app pointing it at %APPDATA%\<app>) sent threadripper to the wrong .codex, while Codex itself locates its home via dirs::home_dir(), which resolves from USERPROFILE and ignores HOME there. That mismatch surfaced as "no Codex state database found under ...\<app>\.codex". Resolve the default home base through a new home_base_from_env(): prefer USERPROFILE on Windows (HOME stays as a fallback for Git Bash/MSYS), keep HOME on Unix. Add cross-platform unit coverage and correct the --codex-home help text.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, when neither
CODEX_HOMEnor--codex-homeis set,codex-threadripperderived the default Codex home as$HOME/.codex, reading only theHOMEenvironment variable.Codex itself locates its home on Windows via
dirs::home_dir(), which resolves fromUSERPROFILEand ignoresHOME. When a process injectsHOMEinto the environment (e.g. an app pointing it at%APPDATA%\<app>), the two diverge: Codex writes its DB underC:\Users\<user>\.codex, while threadripper looked under%APPDATA%\<app>\.codexand failed with:Fix
Introduce a pure
home_base_from_env(userprofile, home, is_windows)that resolves the default home base:USERPROFILE, fall back toHOME(for shells like Git Bash/MSYS that only setHOME)HOMEThe call site passes the platform via
cfg!(windows), so both branches compile and are unit-tested on every platform.Testing
home_base_prefers_userprofile_on_windowscovers: Windows prefersUSERPROFILE(ignoring a hijackedHOME), falls back toHOMEwhenUSERPROFILEis missing/empty, Unix uses onlyHOME, plus an end-to-end repro of the reported issue.cargo fmt --check/cargo test --locked(73 passed) /cargo clippy --locked --all-targets -- -D warningsall green.codex exec review --commit HEAD: no actionable regressions.Compatibility
HOME == USERPROFILE(the common case) the result is unchanged; only whenHOMEis overridden does it now followUSERPROFILE, matching Codex.--codex-home/CODEX_HOMEprecedence is unchanged.