You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(Windows): Path format mismatch causes better-sqlite3 loading failure #1358
This issue is related to #1201 but is a different root cause. #1201 was about Node 25+ compatibility, while this is specifically about Windows path format handling.
Summary: Fixes the Windows path mismatch in apps/memos-local-openclaw/index.ts that caused the @memtensor/memos-local-openclaw-plugin to refuse loading better-sqlite3 even when the native binding sat in its own node_modules/. The plugin's isPathInside(pluginDir, resolvedReal) sandbox guard previously compared /C:/Users/... (from new URL(import.meta.url).pathname) against C:\Users\... (from require.resolve()). The inline normalizeFsPath only stripped the \\?\ long-path prefix and lower-cased, so path.relative() returned a leading-slash absolute path and the guard always failed.
The helpers are now extracted into apps/memos-local-openclaw/src/path-utils.ts and hardened against the five Windows path shapes the runtime can produce: plain backslash, mixed slash, URL-pathname /C:/..., \\?\C:\..., and \\?\UNC\server\share. POSIX behaviour stays case-sensitive. The sandbox semantics are preserved: hoisted-parent and sibling-dir paths still return false. Direct repro of the issue inputs flips from false → true after the fix.
Tests: 21 new table-driven vitest cases in apps/memos-local-openclaw/tests/path-utils.test.ts covering every Windows shape plus POSIX same-dir / child / sibling / case-difference. npx vitest run tests/path-utils.test.ts → 21/21 passed. Regression sanity over the sqlite-independent suites (config, chunker, capture, policy) → 55/55 passed. tsc --noEmit clean. Pre-existing task-processor and update-install failures are environmental (better-sqlite3 native binding skipped via --ignore-scripts) and reproduce on a clean baseline — unrelated to this change.
Files touched (3): apps/memos-local-openclaw/index.ts (import the shared helper, delete the inline copy), apps/memos-local-openclaw/src/path-utils.ts (new), apps/memos-local-openclaw/tests/path-utils.test.ts (new). Specs archived to memos-autodev-specs main (commit 0027420).
Activity
Memtensor-AI commentedon Jun 30, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
6d7408bbcb6ffb3fWorking branch:
bugfix/autodev-1358Target branch:
latest dev* branchWorkflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(memos-local-openclaw): normalize Windows paths in better-sqlite3 …
Memtensor-AI commentedon Jun 30, 2026
✅ AutoDev task
6d7408bbcb6ffb3fcompleted.Summary: Fixes the Windows path mismatch in
apps/memos-local-openclaw/index.tsthat caused the@memtensor/memos-local-openclaw-pluginto refuse loadingbetter-sqlite3even when the native binding sat in its ownnode_modules/. The plugin'sisPathInside(pluginDir, resolvedReal)sandbox guard previously compared/C:/Users/...(fromnew URL(import.meta.url).pathname) againstC:\Users\...(fromrequire.resolve()). The inlinenormalizeFsPathonly stripped the\\?\long-path prefix and lower-cased, sopath.relative()returned a leading-slash absolute path and the guard always failed.The helpers are now extracted into
apps/memos-local-openclaw/src/path-utils.tsand hardened against the five Windows path shapes the runtime can produce: plain backslash, mixed slash, URL-pathname/C:/...,\\?\C:\..., and\\?\UNC\server\share. POSIX behaviour stays case-sensitive. The sandbox semantics are preserved: hoisted-parent and sibling-dir paths still returnfalse. Direct repro of the issue inputs flips fromfalse→trueafter the fix.Tests: 21 new table-driven vitest cases in
apps/memos-local-openclaw/tests/path-utils.test.tscovering every Windows shape plus POSIX same-dir / child / sibling / case-difference.npx vitest run tests/path-utils.test.ts→ 21/21 passed. Regression sanity over the sqlite-independent suites (config,chunker,capture,policy) → 55/55 passed.tsc --noEmitclean. Pre-existingtask-processorandupdate-installfailures are environmental (better-sqlite3 native binding skipped via--ignore-scripts) and reproduce on a clean baseline — unrelated to this change.Files touched (3):
apps/memos-local-openclaw/index.ts(import the shared helper, delete the inline copy),apps/memos-local-openclaw/src/path-utils.ts(new),apps/memos-local-openclaw/tests/path-utils.test.ts(new). Specs archived to memos-autodev-specs main (commit 0027420).Base branch:
mainBranch:
bugfix/autodev-1358Commit:
ee7a340PR: #2005
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Fix #1358: fix(Windows): Path format mismatch causes better-sqlite3 l…