Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Windows: installer tools resolve home as process.env.HOME || "", so ScaffoldUser silently writes its USER tree into the release directory

Open umair-a11y opened this issue 4 months ago • 2 comments

Summary

Most of the v7.28.3 installer tools resolve the home directory as process.env.HOME || "". PowerShell and cmd on Windows do not set HOME (only USERPROFILE), so the empty-string fallback turns every derived path into a relative one and the tools operate on whatever directory they were invoked from. Nothing throws: the install reports success while writing into the extracted release directory.

This is the installer-side sibling of #1694 (runtime process.env.HOME on Windows, still open) and the same failure class as the closed #1463 and #1404: unset HOME producing CWD-relative writes.

Environment

LifeOS v7.28.3 (release tarball)
OS Windows 11 Home 10.0.26200
Harness Claude Code v2.1.220
bun 1.3.14
git 2.51.0.windows.1

What happened

Running setup from PowerShell, Tools/ScaffoldUser.ts reported success with "to": ".config\\LIFEOS\\USER" (a relative path) and created its 102-file USER tree inside the release directory instead of under the user profile.

Repro

  1. Extract the v7.28.3 release tarball on Windows.
  2. From PowerShell (no HOME in the environment), run bun Tools/ScaffoldUser.ts.
  3. The USER tree appears inside the release directory. Tool output shows the relative "to" path and no error.

Affected files (v7.28.3)

const home = process.env.HOME || ""; appears in:

  • Tools/ScaffoldUser.ts:36
  • Tools/LinkUser.ts:36
  • Tools/InstallHooks.ts:31
  • Tools/InstallSettings.ts:36 and :69
  • Tools/ActivateImports.ts:22
  • Tools/DeployComponents.ts:391
  • Tools/SeedPulse.ts:40

Adjacent, same class: the $HOME-expansion prelude at the top of ScaffoldUser.ts, LinkUser.ts, and SeedPulse.ts substitutes process.env.HOME ?? "~" into env values, so with HOME unset those paths degrade to a literal ~/... (the #1463 failure mode: a ~ directory created in CWD).

Suggested fix

The correct pattern already ships in the same directory:

  • Tools/DeployCore.ts:312 has const home = process.env.HOME || homedir();
  • Tools/InstallEngine.ts:166 resolves with homedir() directly (which is what Tools/DetectEnv.ts reports through), and install/LIFEOS/TOOLS/lifeos.ts imports homedir from os.

Aligning the sites above on the DeployCore.ts pattern keeps HOME as an explicit override on every platform and defaults correctly on Windows via os.homedir() (USERPROFILE).

Workaround

Setting HOME before each tool invocation ($env:HOME = $env:USERPROFILE) let the v7.28.3 install complete cleanly. Everything downstream behaved normally afterward, so this resolution pattern was the only blocker in these tools.

umair-a11y avatar Aug 02 '26 18:08 umair-a11y

Same root cause hits at runtime, not just install: pulse.ts expands ~ from process.env.HOME, so Pulse works when started from Git Bash (which sets HOME) but crashes when launched from Task Scheduler or plain PowerShell on Windows 11:

{"level":"error","msg":"Pulse crashed","error":"Error: ENOENT: no such file or directory, open '~\.claude\LIFEOS\PULSE\PULSE.toml'"}

Workaround for anyone hitting this: set HOME=USERPROFILE in whatever launches bun. Proper fix is the same as proposed here — fall back to os.homedir() (which uses USERPROFILE on Windows) everywhere ~ is expanded, not only in installer tools.

umair-a11y avatar Aug 03 '26 06:08 umair-a11y

Good catch, @umair-a11y — the installer tools resolved HOME as an empty string. Fixed in source (skills/LifeOS/Tools now falls back to homedir()), ships next release. Closing since the public repo is generated from that source.

danielmiessler avatar Aug 06 '26 05:08 danielmiessler