fix(windows): resolve platform binary directly and inject HOME env var - #2
Open
Suyujay wants to merge 1 commit into
Open
fix(windows): resolve platform binary directly and inject HOME env var#2Suyujay wants to merge 1 commit into
Suyujay wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
memory_searchsilently degrades to keyword-only (no semantic search) due to two issues:resolveRagBinary()returns a.jsshim that Bun cannot execute via CreateProcess on Windows — error:Executable not found in $PATH$HOMEenv var — the Rustrag.exebinary requires it and fails silentlyThe plugin's
ragSearch()/spawnRagIndex()/downloadModel()all useBun.$orBun.spawnto execute the shim. Both issues cause silent failures with.catch(() => "")fallback, making semantic search appear to work while actually being dead.Root Cause
rag-clialready shipswin32-x64prebuilt binaries (SUPPORTED_PLATFORMSinsrc/platform.jsincludeswin32-x64) — the README just didn't list itresolveRagBinary()resolves the JS shim path, not the actual platform binary — fine on macOS/Linux where Bun can exec shebang files, broken on WindowsFix
src/lib/rag.tsresolveRagBinary(): Prefer the platform-specific binary via@mathew-cf/rag-cli/src/platformresolution, falling back to the JS shim only if platform detection failsragSearch()/downloadModel(): InjectHOME: process.env.HOME || process.env.USERPROFILEviaBun.$.env()spawnRagIndex(): InjectHOMEenv var viaBun.spawn()envoptionREADME.mdUpdated supported platforms: added Windows x64 for rag-cli (previously only listed macOS/Linux).
Verification
bun run typecheckpassesbun run buildsucceeds (dist/index.js + dist/cli.js)memory_searchcorrectly returns semantic results (score 0.40 for natural language queries)