Skip to content

fix(windows): resolve platform binary directly and inject HOME env var - #2

Open
Suyujay wants to merge 1 commit into
mathew-cf:mainfrom
Suyujay:fix/windows-semantic-search
Open

fix(windows): resolve platform binary directly and inject HOME env var#2
Suyujay wants to merge 1 commit into
mathew-cf:mainfrom
Suyujay:fix/windows-semantic-search

Conversation

@Suyujay

Copy link
Copy Markdown

Problem

On Windows, memory_search silently degrades to keyword-only (no semantic search) due to two issues:

  1. resolveRagBinary() returns a .js shim that Bun cannot execute via CreateProcess on Windows — error: Executable not found in $PATH
  2. Windows lacks $HOME env var — the Rust rag.exe binary requires it and fails silently

The plugin's ragSearch()/spawnRagIndex()/downloadModel() all use Bun.$ or Bun.spawn to execute the shim. Both issues cause silent failures with .catch(() => "") fallback, making semantic search appear to work while actually being dead.

Root Cause

  • rag-cli already ships win32-x64 prebuilt binaries (SUPPORTED_PLATFORMS in src/platform.js includes win32-x64) — the README just didn't list it
  • The plugin's resolveRagBinary() resolves the JS shim path, not the actual platform binary — fine on macOS/Linux where Bun can exec shebang files, broken on Windows

Fix

src/lib/rag.ts

  1. resolveRagBinary(): Prefer the platform-specific binary via @mathew-cf/rag-cli/src/platform resolution, falling back to the JS shim only if platform detection fails
  2. ragSearch()/downloadModel(): Inject HOME: process.env.HOME || process.env.USERPROFILE via Bun.$.env()
  3. spawnRagIndex(): Inject HOME env var via Bun.spawn()env option

README.md

Updated supported platforms: added Windows x64 for rag-cli (previously only listed macOS/Linux).

Verification

  • TypeScript: bun run typecheck passes
  • Build: bun run build succeeds (dist/index.js + dist/cli.js)
  • Tests: 147/159 pass; 12 failures are all pre-existing Windows issues (symlink EPERM, ripgrep backslash paths, un-indexed test env) — none introduced by this PR
  • Manual test: After applying this fix to a live Windows installation, memory_search correctly returns semantic results (score 0.40 for natural language queries)

On Windows, Bun cannot exec a .js shim via CreateProcess, causing
semantic search to silently fall back to keyword-only. Fix
resolveRagBinary() to prefer the platform-specific binary (e.g.
rag-cli-win32-x64/bin/rag.exe) and inject HOME env var (which
Windows lacks but the Rust rag binary requires) into all Bun spawn
calls.
Supported platforms in rag-cli already include win32-x64 (confirmed
in src/platform.js SUPPORTED_PLATFORMS). This commit aligns the
plugin code with the actual platform support.
Sign up for freeto 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.

1 participant

@Suyujay