Skip to content

fix(config): honor $HOME for OpenWiki home dir resolution on Windows - #705

Open
XiaoChen (c020627) wants to merge 1 commit into
langchain-ai:mainfrom
c020627:fix-home-env-isolation
Open

fix(config): honor $HOME for OpenWiki home dir resolution on Windows#705
XiaoChen (c020627) wants to merge 1 commit into
langchain-ai:mainfrom
c020627:fix-home-env-isolation

Conversation

@c020627

Copy link
Copy Markdown
Contributor

Problem

On Windows, os.homedir() reads USERPROFILE and silently ignores process.env.HOME. The test suite and local dev tooling isolate state by pointing $HOME at a throwaway directory, but that isolation was a no-op on Windows — onboarding/config tests wrote into the real ~/.openwiki instead of the isolated path (see #695).

Solution

src/config/openwiki-home.ts now resolves the user home through a new resolveUserHomeDir() helper that honors process.env.HOME when set and falls back to os.homedir() otherwise. resolveOpenWikiHomeDir() uses it at every call site. POSIX behavior is unchanged (os.homedir already returns $HOME there), so this only affects Windows isolation.

Testing

  • Added test/config/openwiki-home-home-env.test.ts with 5 cases covering: $HOME honored when set, os.homedir() fallback when unset, and OPENWIKI_CONFIG_DIR / ~ / ~/sub expansion against $HOME.
  • npx vitest run test/config/openwiki-home-home-env.test.ts → 5 passed.
  • npx tsc --noEmit -p tsconfig.json → clean.
  • Added a patch changeset (.changeset/fix-home-env-isolation.md).

Fixes #695

On Windows `os.homedir()` reads `USERPROFILE` and silently ignores
`process.env.HOME`, so pointing `$HOME` at a throwaway directory (the
isolation strategy used by the test suite and local dev tooling) had no
effect on Windows. `resolveOpenWikiHomeDir` now resolves the user home
via `resolveUserHomeDir`, which honors `$HOME` when set and falls back to
`os.homedir()` otherwise. POSIX behavior is unchanged.

Fixes langchain-ai#695

Co-Authored-By: WorkBuddy <noreply@workbuddy.ai>
@changeset-bot

changeset-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5260635

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openwiki Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: onboarding tests write into the real ~/.openwiki on Windows and corrupt it

1 participant