Skip to content

fix(installer): honor CODEX_HOME for the Codex global install (#1627) - #1633

Open
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/1627-codex-home
Open

fix(installer): honor CODEX_HOME for the Codex global install (#1627)#1633
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/1627-codex-home

Conversation

@maxmilian

Copy link
Copy Markdown
Contributor

Addresses the CODEX_HOME half of #1627.

Codex resolves its user layer from CODEX_HOME and only falls back to ~/.codex. The Codex target hardcoded the fallback, so a user running Codex against a custom profile got a correct install into a directory Codex never reads — the [mcp_servers.codegraph] entry, the AGENTS.md block, and detect() all pointed at the default profile. Nothing errors; CodeGraph simply never loads.

Resolution now mirrors what the copilot-cli target already does for COPILOT_HOME:

const override = process.env.CODEX_HOME;
if (override && override.trim().length > 0) return override;
return path.join(os.homedir(), '.codex');

Only the user layer moves. The project layer from #1531 stays anchored to the project — .codex/config.toml beside the repo is not a profile artifact — and there is a test pinning that.

Scope: this is deliberately half of #1627

The issue names two variables. The CLAUDE_CONFIG_DIR half is already handled by #1029 (open since June, rebased onto current main on Aug 25, waiting on review) — it was opened before this issue existed, so the two aren't linked in either direction. This PR does not touch targets/claude.ts, so the two don't collide. Landing both closes #1627.

Tests

Four cases in a new describe, following the shape of the existing opencode XDG config path (#535) block:

One extra fix in the harness: setHome() clears HERMES_HOME and COPILOT_HOME but not CODEX_HOME. Now that the target reads it, the existing codex tests would fail on any machine that has the variable exported, so it is cleared and restored alongside the other two.

Full suite: 178 files / 3056 tests passing (3052 on main plus these four). npm run build clean.

Reported by @seanchann.

…chenry#1627)

Codex resolves its user layer from `CODEX_HOME` and only falls back to
`~/.codex`. The target hardcoded the fallback, so a user on a custom profile
got a correct install into a directory Codex never reads — the MCP entry, the
AGENTS.md block, and detect() all pointed at the wrong profile, and the
failure is silent.

Resolve the global config dir from `CODEX_HOME` when set and non-blank,
mirroring what the copilot-cli target already does for `COPILOT_HOME`. Only
the user layer moves; the project layer (colbymchenry#1531) stays anchored to the project.

The test harness now also clears `CODEX_HOME` in setHome() alongside
HERMES_HOME/COPILOT_HOME — without that, the existing codex tests fail on a
developer machine that has the variable exported.

Note this is only half of colbymchenry#1627: the CLAUDE_CONFIG_DIR half is already
covered by the open PR colbymchenry#1029, which this deliberately does not touch.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

codegraph install ignores CLAUDE_CONFIG_DIR and CODEX_HOME environment variables

1 participant