Skip to content

fix: complete Windows compatibility for path handling in qmd.ts#143

Open
faisalkindi wants to merge 2 commits intotobi:mainfrom
faisalkindi:windows-support
Open

fix: complete Windows compatibility for path handling in qmd.ts#143
faisalkindi wants to merge 2 commits intotobi:mainfrom
faisalkindi:windows-support

Conversation

@faisalkindi
Copy link

Summary

Building on PR #137's store.ts fixes (HOME fallback, mkdirSync, sqlite-vec DLL, bin entry), this PR addresses the remaining Windows compatibility issues in qmd.ts to fully resolve #31.

Changes

Path resolution (startsWith checks)

  • Replace all startsWith('/') absolute path checks with isAbsolutePath() (already exported from store.ts) which correctly handles Windows drive letters (C:\, D:\) and Git Bash paths (/c/)
  • Affected functions: contextAdd, contextRemove, getDocument, listFiles

Path normalization (split operations)

  • Add normalizePathSeparators() before all split('/') operations on filesystem paths to handle Windows backslashes
  • Affected functions: computeDisplayPath, getDocument, listFiles, collectionAdd, detectCollectionFromPath

Collection path matching

  • Normalize both real paths and collection paths in detectCollectionFromPath() so C:\Users\... matches correctly against stored collection paths

Shell command spawning

  • Use cmd /c on Windows instead of /usr/bin/env bash -c for custom collection update commands

Combined with PR #137, this resolves all 8 issues from #31:

  1. ✅ Bash shebang → bin entry points to .ts (PR fix: Windows compatibility for HOME path, mkdir, and sqlite-vec loading #137)
  2. mkdir -pmkdirSync (PR fix: Windows compatibility for HOME path, mkdir, and sqlite-vec loading #137)
  3. ✅ Path resolution assumes Unix → isAbsolutePath() (this PR)
  4. ✅ HOME fallback → USERPROFILE (PR fix: Windows compatibility for HOME path, mkdir, and sqlite-vec loading #137)
  5. ✅ Hardcoded / separators → normalizePathSeparators() (this PR)
  6. ✅ sqlite-vec loading → Windows DLL fallback (PR fix: Windows compatibility for HOME path, mkdir, and sqlite-vec loading #137)
  7. ⬜ Tests with Unix paths (non-blocking, can be addressed separately)
  8. ⬜ Nix flake excludes Windows (non-blocking)

Test plan

Fixes #31

sarukas and others added 2 commits February 8, 2026 18:33
- Use USERPROFILE fallback when HOME env var is not set (Windows cmd.exe)
- Replace Unix-only `mkdir -p` shell command with cross-platform mkdirSync
- Add Windows fallback for sqlite-vec DLL loading via absolute path
- Point bin entry to src/qmd.ts so bun shim works on Windows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Building on PR tobi#137's store.ts fixes, this addresses the remaining
Windows compatibility issues in qmd.ts:

- Replace all startsWith('/') checks with isAbsolutePath() to handle
  Windows drive letters (C:\)
- Normalize backslash paths with normalizePathSeparators() before
  split('/') operations throughout the codebase
- Fix collection path matching in detectCollectionFromPath() to
  normalize both real paths and collection paths
- Use cmd /c on Windows instead of bash -c for custom update commands

These changes, combined with PR tobi#137, resolve all 8 issues from tobi#31.

Fixes tobi#31
@faisalkindi
Copy link
Author

Testing Results on Windows 11

Tested on Windows 11 x64 with Bun v1.3.9:

✅ Working

  • qmd status — correct Windows path (C:/Users/...)
  • qmd collection add . --name test --mask "*.md" — indexes files successfully
  • qmd search "query" — returns results with correct paths and scores
  • qmd collection remove — works correctly
  • qmd collection list — shows collections properly

⚠️ Bun Bug (not our code)

  • **/*.md recursive glob causes Bun to crash with panic: invalid enum value
  • This is a known Bun issue on Windows (oven-sh/bun#14844, duplicate of #15964)
  • Workaround: use non-recursive glob (*.md) and add collections per-directory
  • Non-recursive globs work perfectly

Environment

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.

Windows Support: Multiple compatibility issues prevent usage on Windows

2 participants

Comments