Skip to content

fix: add USERPROFILE fallback for Windows HOME resolution#555

Merged
tobi merged 1 commit intotobi:mainfrom
max0n232:fix/windows-home-fallback
Apr 11, 2026
Merged

fix: add USERPROFILE fallback for Windows HOME resolution#555
tobi merged 1 commit intotobi:mainfrom
max0n232:fix/windows-home-fallback

Conversation

@max0n232
Copy link
Copy Markdown
Contributor

Problem

On Windows, HOME is not a standard environment variable — the equivalent is USERPROFILE. When MCP clients (e.g. Claude Code) spawn the QMD server as a subprocess, they pass USERPROFILE but not HOME.

store.ts:41:

const HOME = process.env.HOME || "/tmp";

This causes QMD to fall back to /tmp, creating/opening an empty database at /tmp/.cache/qmd/index.sqlite instead of ~/.cache/qmd/index.sqlite. The CLI works because shells like Git Bash/MSYS2 set HOME, but MCP subprocesses spawned via cmd /c node or direct node do not.

Symptom: qmd status via CLI shows 552 docs, but MCP status tool returns 0 documents.

Fix

const HOME = process.env.HOME || process.env.USERPROFILE || "/tmp";

One-line change. USERPROFILE is always set on Windows. Falls through to /tmp on systems where neither is set (shouldn't happen in practice).

Environment

  • QMD 2.0.1
  • Windows 11
  • Node.js 24.12.0
  • Claude Code 2.1.92 (MCP client)

On Windows, `HOME` is not a standard environment variable — the
equivalent is `USERPROFILE`. When MCP clients (e.g. Claude Code)
spawn the QMD server as a subprocess, they pass `USERPROFILE` but
not `HOME`. This causes QMD to fall back to `/tmp`, opening an
empty database instead of the user's actual index.

Fix: check `USERPROFILE` before falling back to `/tmp`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants