Skip to content

fix(codex): canonicalize junction-backed default Codex home - #5865

Closed
pjhsion wants to merge 1 commit into
lidge-jun:devfrom
pjhsion:fix/windows-junction-codex-home
Closed

pjhsion wants to merge 1 commit into
lidge-jun:devfrom
pjhsion:fix/windows-junction-codex-home

Conversation

@pjhsion

@pjhsion pjhsion commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #5864

Windows users who move Codex state to another volume often keep %USERPROFILE%/.codex as a directory junction. The default Codex-home resolver previously returned that lexical junction path, so the Windows packaged Bun runtime could not safely canonicalize it later during native-profile/account handling and Codex account settings returned HTTP 500.

This change canonicalizes an existing default Codex home with the portable realpath resolver before the path reaches credential and native-profile writers. Missing or unreadable homes retain the existing lexical-path fallback, and WSL discovery behavior is unchanged. A Windows-only regression test creates a real junction and asserts that the physical target is returned.

Verification

  • bun test tests/codex-integration/codex-home-wsl.test.ts — 11 pass
  • bun test tests/codex-integration/native-profile-store.test.ts — 15 pass, 1 skip
  • bun run typecheck — passed
  • bun run structure:check — passed
  • bun run privacy:scan — passed
  • git diff --check — passed
  • The full bun run test:changed gate was started against dev but exceeded the local 300-second execution budget; it was terminated after the focused tests and fast repository gates had passed. CI should provide the broader suite result.
  • The repository does not contain scripts/typescript/check-no-excuse-rules.ts, so that optional audit command was unavailable.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 61 / 80

이 글은 Windows에서 Codex 집이 다른 디스크를 가리킬 때, 계정 목록이 안 열리는 문제를 고쳐요.

%USERPROFILE%\.codex를 D:\CodexState 같은 실제 폴더에 연결해 두면, 예전 코드는 그 연결 이름 그대로를 집으로 냈어요. 설치본 Bun은 realpathSync.native로 그 이름을 실제 폴더로 확정하지 못해요. 이슈 #5864는 그때 계정 조회가 HTTP 500이고, 오류 문장이 The effective CODEX_HOME is not an accessible directory라고 해요. CODEX_HOME을 실제 폴더로 지정하면 같은 프로그램이 계정을 열어요.

고침은 기본 집을 정할 때, 그 폴더가 있으면 연결을 풀어서 실제 경로를 내게 해요. 폴더가 없거나 읽지 못하면 예전 이름을 남겨요. WSL이 Windows 집을 찾는 동작은 그대로예요. Windows에서만 연결을 만들고, 돌아온 경로가 실제 폴더와 같은지 보는 테스트를 넣었어요.

라인 - src/codex/home.ts canonicalExistingCodexHome. 그 오류 문장을 던지는 곳은 src/codex/native-profile-store.ts의 canonicalExistingDirectory예요. 거기는 아직도 realpathSync.native를 써요. 이 글은 그 함수에 들어가기 전에 실제 폴더를 넣어요. 실제 폴더에서는 native가 된다는 이슈의 확인과 맞아요. 다만 연결을 푸는 realpathSync도 실패하면 catch가 오류를 삼키고 연결 이름을 그대로 돌려요. 그러면 같은 실패가 남아요. 새 테스트는 defaultCodexHome이 돌려준 글자만 확인해요. resolveNativeProfileContext는 부르지 않아요. Windows가 아니면 테스트를 건너뛰어서, 리눅스 CI는 연결을 만들지 않아요. 작성자도 넓은 테스트 test:changed를 300초에 끊었어요.

메인테이너의 판단이 필요한 지점

환경변수 CODEX_HOME에 연결 이름을 직접 넣으면, src/codex/paths.ts resolveCodexHome이 여전히 realpathSync.native를 불러요. 이번 이슈는 환경변수를 비운 경우라 그 함수는 실행되지 않아요. 환경변수로 연결 이름을 준 경우까지 고칠지 정해 주세요.

이 함수는 연결만이 아니라, 이미 있는 기본 집이면 항상 실제 경로를 돌려요. 계정 저장 이름(home id)은 native-profile이 native 경로로 다시 해시해요. native가 성공하면 예전 키와 같아야 해요. getCodexHome()이 돌려주는 글자는 대소문자가 달라질 수 있어요. 그 글자를 그대로 키로 쓰는 곳이 있는지는 봐 주세요.

아직 초안이고, 준비 체크는 네 칸 모두 비어 있어요. Windows에서 연결 집으로 계정 목록이 열리는지 보고 머지할지 정해 주세요.

너의 추천

바탕은 dev가 맞아요. types.ts와 config.ts를 나누는 일과 겹쳐서 닫을 중복은 없어요. 닫지 마세요. 실패하면 연결 이름으로 조용히 돌아가지 않게 하고, Windows에서 resolveNativeProfileContext까지 통과한 뒤에 넣으면 돼요.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun

Copy link
Copy Markdown
Owner

Thanks! This landed on dev through the bug-PR merge train batch #5901 (merge dd1e327). Your change was carried as one squashed commit that keeps you as the commit author, with a Co-authored-by trailer. Closing this PR since its content is now on dev.

@lidge-jun lidge-jun closed this Sep 26, 2026
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 26, 2026
…n#5865)

Squashed carry of lidge-jun#5865.

Closes lidge-jun#5864

Co-authored-by: pjhsion <pjhsion@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants