Skip to content

fix(config): treat an empty HOME as unset - #2332

Closed
kaoru0822-kitauji wants to merge 1 commit into
mainfrom
fix/issue-2325
Closed

kaoru0822-kitauji wants to merge 1 commit into
mainfrom
fix/issue-2325

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

homeDirectoryFromEnvironment (src/config/homeDirectory.ts) chose the home with ??, so an empty HOME (or USERPROFILE / HOMEDRIVE / HOMEPATH on Windows) was used as the home. Every path joined onto it became relative. With HOME="", rea setup wrote .cursor/mcp.json and .agents/skills/reverse-engineer-anything/… into the current working directory and reported ready. Run from a project checkout, that writes REA configuration into the repository, and the real client configuration is never registered. doctor, uninstall and config parsing use the same value.

Empty home variables are now treated as unset, so resolution falls back to the account home, as shells and most tools do. A non-empty selected home, including relative values, is unchanged.

This is the HOME counterpart of #2168 / #2189 (empty XDG_CONFIG_HOME for OpenCode).

Fixes #2325

Before / after (empty working directory, env -i PATH="$PATH" HOME="" rea setup --client cursor --dry-run --json)

before: configure_client:cursor → .cursor/mcp.json
        install_skill → .agents/skills/reverse-engineer-anything
after:  configure_client:cursor → /Users/<account>/.cursor/mcp.json
        install_skill → /Users/<account>/.agents/skills/reverse-engineer-anything

Before the change, a non-dry-run --yes in an empty directory created ./.cursor/mcp.json and ./.agents/skills/reverse-engineer-anything/SKILL.md.

Validation

  • src/config.test.ts (home directory selection) covers empty HOME on darwin, empty HOME + USERPROFILE on linux, all-empty variables on win32, a selected home kept as-is, and the Windows fallback past an empty USERPROFILE to HOMEDRIVE+HOMEPATH and then HOME. The four new tests fail on main and pass with this change; 44/44 in the file pass. They are unit tests so they never read or write the real account home; the end-to-end check above was a dry run.
  • npm run lint passes.
  • npm test: 9833 passed, 17 failed in 9 files. All of them also fail on clean origin/main (f611d8c) on this host:
    • 7 environmental files: Hopper, ibtool, hdiutil, inspector target locations.
    • processSettlementDeadline (macOS cannot observe /bin/sleep's environment).
    • tests/boundary/cli/referenceSourceImportStatus.test.ts: 2 full-output cases expect the wrapper's ok: true for a failed import, which main's recent full-output failure-semantics change appears to have altered.

🤖 Generated with Claude Code

homeDirectoryFromEnvironment selected HOME (or USERPROFILE, HOMEDRIVE,
HOMEPATH) with ??, so an empty value was used as the home. Every path
joined onto it became relative, and rea setup wrote client
registrations and the REA skill into the working directory while
reporting ready. Treat empty home variables as unset and fall back to
the account home, as shells and most tools do.

Fixes #2325

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

Superseded by c339f9e (fix(setup): ignore empty home directory selections), which fixed #2325 on main with the same precedence and broader setup/doctor/uninstall coverage. The CI failures here came from main-side test breakage already fixed by 8224aeb and ac57c88. Closing. (AI agent maintenance loop.)

@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/issue-2325 branch October 13, 2026 03:20
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks, @kaoru0822-kitauji, for catching the empty-HOME case that could redirect configuration writes into the current directory. Main now shares a safe fallback across setup, doctor, and uninstall (main).

@morluto morluto added the area: setup Setup, packaging, upgrade, install, Doctor, and client registration label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] An empty HOME makes rea setup write client configs and the skill into the working directory

2 participants