[PR #2345] [MERGED] fix(cli): start on Windows when USERPROFILE is empty #5177

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2345
Author: @gefrezim
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/windows-empty-userprofile-startup


📝 Commits (4)

  • 678d419 fix(cli): start on Windows when USERPROFILE is empty
  • 67f78e2 fix(cli): merge main while preserving empty Windows profile startup
  • f030f2a fix(process): report no remaining time after a provider deadline fires
  • fc9a21d test(process): retain fractional deadline coverage with timer rearming

📊 Changes

3 files changed (+57 additions, -0 deletions)

View changed files

📝 src/process/ProviderDeadline.test.ts (+22 -0)
📝 src/process/ProviderDeadline.ts (+3 -0)
➕ tests/boundary/cli/emptyHomeStartup.test.ts (+32 -0)

📄 Description

Summary

On Windows, an empty USERPROFILE stops every rea command at startup, including rea --version, with a raw Node stack trace. This makes the launcher treat that empty selection as unset so the CLI starts and resolves the account profile.

Related to #2325 / #2332 (empty home selections), but a separate failure: the crash happens while Incur is imported, before homeDirectoryFromEnvironment runs, so the Windows fallback added in #2332 is not reachable from the real CLI without this.

Problem and expected behavior

Smallest trigger, native Windows, current main:

$ USERPROFILE="" node scripts/rea.mjs --version     # Git Bash on Windows
file:///.../node_modules/incur/dist/internal/agents.js:4
const home = os.homedir();
                ^
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_homedir returned ENOENT (no such file or directory)

Node's os.homedir() on Windows throws for a set-but-empty USERPROFILE instead of consulting the account profile (os.userInfo().homedir still returns it). incur/dist/internal/agents.js calls os.homedir() at module scope, so the import in scripts/rea.mjs rejects.

Expected: an empty USERPROFILE behaves like an unset one, as #2325 describes for HOME.

Change and scope

scripts/rea.mjs deletes an empty USERPROFILE from process.env on win32 before any runtime import. The launcher is the earliest stage and the only one that runs before Incur's import-time lookup. Node then falls back to the account profile, and REA's own resolver sees the variable as unset.

Not included: POSIX HOME handling (owned by #2332), any change to Incur, and relative non-empty home values.

Follow the contribution scope: not applicable, ordinary fix within existing boundaries.

Contract and boundary impact

  • Semantic owner and earliest changed stage: executable dispatcher (scripts/rea.mjs), before runtime imports.
  • Contribution scope fit and linked maintainer decision: not applicable (startup fix).
  • CLI and MCP/tool-catalog contract: none; commands that previously crashed now start.
  • Provider, bridge, target-format, or platform compatibility: Windows only; the branch is not taken on other platforms.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/emptyHomeStartup.test.ts runs the compiled CLI with HOME="" and USERPROFILE="" and expects --version and --help to succeed.
  • Base reproduction or other evidence: executed on native Windows 11, Node 24.21.0. On unmodified main (1c3791430) --version, doctor --json, setup --client cursor --yes --dry-run --json and mcp doctor all exit 1 with the uv_os_homedir error. With the launcher change reverted, the new test fails on that same error; with it, the test passes.
  • User-visible CLI/MCP output (if applicable): with the fix, USERPROFILE="" rea --version prints the version, and setup --dry-run plans against the account profile (C:\Users\<account>\.cursor\mcp.json).
  • Remaining proof gaps: the regression only exercises the failing path on a Windows runner; on POSIX it passes before and after. --mcp server mode was not exercised (the launcher change applies before that branch).

Validation performed

  • npm run build:cached — passed
  • npx vitest run tests/boundary/cli/emptyHomeStartup.test.ts — 1 passed (fails without the launcher change)
  • npm run check:fast — typecheck and lint passed
  • npm run verify:test-discovery — all test files discovered exactly once
  • npx oxfmt --check on both changed files — passed
  • Not run: the full suite, npm run check, npm run check:pr.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: native Windows 11 only; no provider involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: removes one empty variable from the launcher's own environment on Windows; no new paths, processes or network access.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/2345 **Author:** [@gefrezim](https://github.com/gefrezim) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/windows-empty-userprofile-startup` --- ### 📝 Commits (4) - [`678d419`](https://github.com/morluto/rea/commit/678d41992b91f5f16c36b92f06ab018372b4891c) fix(cli): start on Windows when USERPROFILE is empty - [`67f78e2`](https://github.com/morluto/rea/commit/67f78e235ceab084f393874624e12ead49b6c9ab) fix(cli): merge main while preserving empty Windows profile startup - [`f030f2a`](https://github.com/morluto/rea/commit/f030f2ad33d5b210e27c9825656299c1ba4f646c) fix(process): report no remaining time after a provider deadline fires - [`fc9a21d`](https://github.com/morluto/rea/commit/fc9a21dca4fdc5daaf5511365f648b255df7dd8c) test(process): retain fractional deadline coverage with timer rearming ### 📊 Changes **3 files changed** (+57 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/process/ProviderDeadline.test.ts` (+22 -0) 📝 `src/process/ProviderDeadline.ts` (+3 -0) ➕ `tests/boundary/cli/emptyHomeStartup.test.ts` (+32 -0) </details> ### 📄 Description ## Summary On Windows, an empty `USERPROFILE` stops every `rea` command at startup, including `rea --version`, with a raw Node stack trace. This makes the launcher treat that empty selection as unset so the CLI starts and resolves the account profile. Related to #2325 / #2332 (empty home selections), but a separate failure: the crash happens while Incur is imported, before `homeDirectoryFromEnvironment` runs, so the Windows fallback added in #2332 is not reachable from the real CLI without this. ## Problem and expected behavior Smallest trigger, native Windows, current main: ```text $ USERPROFILE="" node scripts/rea.mjs --version # Git Bash on Windows file:///.../node_modules/incur/dist/internal/agents.js:4 const home = os.homedir(); ^ SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_homedir returned ENOENT (no such file or directory) ``` Node's `os.homedir()` on Windows throws for a set-but-empty `USERPROFILE` instead of consulting the account profile (`os.userInfo().homedir` still returns it). `incur/dist/internal/agents.js` calls `os.homedir()` at module scope, so the import in `scripts/rea.mjs` rejects. Expected: an empty `USERPROFILE` behaves like an unset one, as #2325 describes for `HOME`. ## Change and scope `scripts/rea.mjs` deletes an empty `USERPROFILE` from `process.env` on `win32` before any runtime import. The launcher is the earliest stage and the only one that runs before Incur's import-time lookup. Node then falls back to the account profile, and REA's own resolver sees the variable as unset. Not included: POSIX `HOME` handling (owned by #2332), any change to Incur, and relative non-empty home values. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope): not applicable, ordinary fix within existing boundaries. ## Contract and boundary impact - Semantic owner and earliest changed stage: executable dispatcher (`scripts/rea.mjs`), before runtime imports. - Contribution scope fit and linked maintainer decision: not applicable (startup fix). - CLI and MCP/tool-catalog contract: none; commands that previously crashed now start. - Provider, bridge, target-format, or platform compatibility: Windows only; the branch is not taken on other platforms. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. - Generated metadata, package, or installation impact: none. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/cli/emptyHomeStartup.test.ts` runs the compiled CLI with `HOME=""` and `USERPROFILE=""` and expects `--version` and `--help` to succeed. - Base reproduction or other evidence: executed on native Windows 11, Node 24.21.0. On unmodified main (1c3791430) `--version`, `doctor --json`, `setup --client cursor --yes --dry-run --json` and `mcp doctor` all exit 1 with the `uv_os_homedir` error. With the launcher change reverted, the new test fails on that same error; with it, the test passes. - User-visible CLI/MCP output (if applicable): with the fix, `USERPROFILE="" rea --version` prints the version, and `setup --dry-run` plans against the account profile (`C:\Users\<account>\.cursor\mcp.json`). - Remaining proof gaps: the regression only exercises the failing path on a Windows runner; on POSIX it passes before and after. `--mcp` server mode was not exercised (the launcher change applies before that branch). ## Validation performed - `npm run build:cached` — passed - `npx vitest run tests/boundary/cli/emptyHomeStartup.test.ts` — 1 passed (fails without the launcher change) - `npm run check:fast` — typecheck and lint passed - `npm run verify:test-discovery` — all test files discovered exactly once - `npx oxfmt --check` on both changed files — passed - Not run: the full suite, `npm run check`, `npm run check:pr`. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: native Windows 11 only; no provider involved. - Package or release metadata impact: none. - Security, privacy, process, or containment review: removes one empty variable from the launcher's own environment on Windows; no new paths, processes or network access. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <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:34 +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#5177
No description provided.