fix(ruv-swarm): use fileURLToPath for module paths (fixes Windows C:\C:\ path bug)#192
Open
k2jac9 wants to merge 1 commit into
Open
fix(ruv-swarm): use fileURLToPath for module paths (fixes Windows C:\C:\ path bug)#192k2jac9 wants to merge 1 commit into
k2jac9 wants to merge 1 commit into
Conversation
On Windows, `new URL('.', import.meta.url).pathname` returns a leading-slash,
drive-prefixed string (e.g. `/C:/.../src/`). Passing that through `path.join`
produces `\C:\...`, which fs operations then resolve against the cwd drive into
the invalid doubled-drive path `C:\C:\...`. This makes the SQLite persistence
layer fail to initialize at startup ("Failed to initialize pooled persistence …
ENOENT … mkdir 'C:\C:\...\data'") and also breaks WASM / checksum path
resolution.
Fix by using `fileURLToPath()` (the correct file: URL -> path API) instead of
`.pathname`. This is correct on all platforms and a no-op on POSIX.
Affected modules: persistence.js, persistence-pooled.js, index.js, security.js,
wasm-loader2.js, sqlite-pool.js (8 path constructions total).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Quick context for triage: this hits every Windows user on Root cause is just Happy to add a regression test or split per-file if you'd prefer. |
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 free
to 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.
Summary
Fixes broken module-path resolution on Windows in
ruv-swarmcaused by usingnew URL('.', import.meta.url).pathnameto locate files relative to a module.On Windows,
new URL('.', import.meta.url).pathnamereturns a leading-slash, drive-prefixed string such as/C:/Users/.../ruv-swarm/src/. Feeding that intopath.join(...)produces\C:\Users\..., and when anfscall later resolves that against the current drive you get the invalid doubled-drive pathC:\C:\Users\....Symptom
Every
ruv-swarminvocation on Windows prints:The SQLite persistence layer never initializes (swarm state/memory is not saved), and the same broken construction is used for the WASM directory and the integrity-checksum path, so those are affected too.
Fix
Replace
new URL(...).pathnamewithfileURLToPath(...)fromnode:url, which is the correctfile:URL → filesystem path conversion. It produces a proper native path on Windows and is a no-op on POSIX (/home/...stays/home/...).8 path constructions across 6 modules:
src/persistence.jssrc/persistence-pooled.jssrc/index.jssrc/security.jssrc/wasm-loader2.jssrc/sqlite-pool.jsTest evidence
Before:
ruv-swarm init mesh 3fails persistence init with theC:\C:\...ENOENT above.After (Windows 11, Node 25):
No behavior change on POSIX. No dependency or API changes — purely a path-resolution correctness fix.