[PR #2332] [CLOSED] fix(config): treat an empty HOME as unset #5168

Closed
opened 2026-10-31 01:04:30 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2332
Author: @kaoru0822-kitauji
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-2325


📝 Commits (1)

  • e4278e5 fix(config): treat an empty HOME as unset

📊 Changes

2 files changed (+49 additions, -8 deletions)

View changed files

📝 src/config.test.ts (+36 -0)
📝 src/config/homeDirectory.ts (+13 -8)

📄 Description

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 (f611d8ce7) 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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2332 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-2325` --- ### 📝 Commits (1) - [`e4278e5`](https://github.com/morluto/rea/commit/e4278e54d0c69a166ab052637e52db2c1dfb682d) fix(config): treat an empty HOME as unset ### 📊 Changes **2 files changed** (+49 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/config.test.ts` (+36 -0) 📝 `src/config/homeDirectory.ts` (+13 -8) </details> ### 📄 Description ## 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`) ```text 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` (f611d8ce7) 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5168
No description provided.