Skip to content

feat: support CODEX_HOME override#51

Open
DRanger666 wants to merge 1 commit intoLoongphy:mainfrom
DRanger666:feat/codex-home-override
Open

feat: support CODEX_HOME override#51
DRanger666 wants to merge 1 commit intoLoongphy:mainfrom
DRanger666:feat/codex-home-override

Conversation

@DRanger666
Copy link
Copy Markdown

Title:

feat: support CODEX_HOME override

Description:

Summary

This PR adds CODEX_HOME support to codex-auth.

Current behavior only resolves the Codex state root from:

  • HOME/.codex
  • USERPROFILE/.codex on Windows

After this change, resolution order becomes:

  1. CODEX_HOME when set to a non-empty path
  2. HOME/.codex
  3. USERPROFILE/.codex on Windows

This keeps existing behavior intact while allowing users to keep
Codex auth, registry, config, and session state in a custom
location.

What changed

  • added CODEX_HOME precedence in the Codex home resolver
  • kept existing fallback behavior for HOME/.codex and
    USERPROFILE/.codex
  • updated docs to describe the new storage-root resolution order
  • updated e2e tests to set an explicit test-local CODEX_HOME so
    they do not depend on ambient user environment state
  • added resolver tests covering:
    • CODEX_HOME override
    • empty CODEX_HOME fallback to HOME
    • USERPROFILE fallback when HOME is unset

Why

Some users run Codex with a custom CODEX_HOME and expect
related tooling to operate on the same state root. Without this
change, codex-auth always targets the default home-based path,
which makes it diverge from the active Codex environment.

Validation

Validated with the project test suite using Zig 0.15.1.

  • zig build
  • zig test src/main.zig -lc

Result:

  • all 273 tests passed

Compatibility

This change is backward-compatible:

  • existing users without CODEX_HOME set still use HOME/.codex
  • Windows fallback behavior remains in place
  • test coverage was updated to preserve and verify the old
    behavior alongside the new override behavior

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2026

Open in StackBlitz

@loongphy/codex-auth-darwin-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-arm64@51

@loongphy/codex-auth-darwin-x64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-x64@51

@loongphy/codex-auth-linux-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-arm64@51

@loongphy/codex-auth-linux-x64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-x64@51

@loongphy/codex-auth-win32-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-arm64@51

@loongphy/codex-auth-win32-x64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-x64@51

@loongphy/codex-auth

npx https://pkg.pr.new/@loongphy/codex-auth@51

commit: 82ebeaa

@Loongphy
Copy link
Copy Markdown
Owner

Thanks for your contribution.

It was supported in early versions but was removed in a later release. It's meaningful and also convenient for testing, let's restore it.

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.

2 participants