Path Bug: Nested Windows Paths in WSL Environment
Bug Description
When using Basic Memory in a WSL environment with a project that has a Windows-style path, Basic Memory creates incorrectly nested directory structures mixing Windows and Linux path formats.
Environment
- OS: WSL2 (Windows Subsystem for Linux)
- Basic Memory version: (latest as of July 31, 2025)
- Project: shadow-ln
- Expected path:
/mnt/c/Users/Dr Brenda/basic-memory/housing/shadow-ln/
Steps to Reproduce
- Set up Basic Memory in WSL with a project pointing to a Windows path
- Switch to the project using
switch_project("shadow-ln") - Create a note using
write_note()with folder parameter "legal-research" - Check the file system for the created file
Expected Behavior
Files should be created at:
/mnt/c/Users/Dr Brenda/basic-memory/housing/shadow-ln/legal-research/filename.md
Actual Behavior
Files are created at a nested path combining Windows and Linux formats:
/mnt/c/Users/Dr Brenda/basic-memory/C:\Users\Dr Brenda\basic-memory\housing\shadow-ln/legal-research/filename.md
Note the incorrect nesting: /mnt/c/Users/Dr Brenda/basic-memory/C:\Users\...
Impact
- Files are not created in the expected location
- Breaks integration with other tools expecting standard file paths
- Creates confusion about where files are actually stored
sync_statusreports everything is fine even though files are in wrong location
Workaround
Manually move files from the nested path to the correct location:
mv "/mnt/c/Users/Dr Brenda/basic-memory/C:\Users\Dr Brenda\basic-memory\housing\shadow-ln/legal-research/"*.md /mnt/c/Users/Dr\ Brenda/basic-memory/housing/shadow-ln/legal-research/
Additional Notes
- The
list_directorycommand shows files in the expected structure, but the actual file system has them in the nested path - This appears to be a path resolution issue when Basic Memory handles Windows-style paths in a WSL environment
@claude has this issue been fixed? if so, should we make a test to assert the correct behavior?
Claude encountered an error —— View job • claude/issue-243-20250926-1447 • Create PR ➔
Analysis Complete ✅
I've investigated the WSL path bug and created comprehensive tests to verify the correct behavior.
Todo List:
- [x] Search for path handling code related to WSL/Windows environments
- [x] Check for existing tests related to path resolution
- [x] Determine if the bug has been fixed
- [x] Create a test case for WSL path resolution
- [x] Verify the test works correctly
- [x] Commit and push changes
Findings
Has the bug been fixed?
The bug has NOT been explicitly fixed yet. After reviewing the codebase:
-
Root cause identified: The issue appears to be in
src/basic_memory/services/project_service.pyline 103, where Windows paths are resolved usingPath(os.path.abspath(os.path.expanduser(path))).as_posix(). This doesn't properly handle Windows-style paths (likeC:\Users\...) when running in WSL. -
Secondary issue: In
src/basic_memory/schemas/base.pyline 227, thefile_pathproperty usesos.path.join()which could potentially compound the issue when mixing path styles.
Test Created
I've created a comprehensive test suite in tests/services/test_wsl_path_handling.py that:
✅ Tests Windows path conversion in WSL environments ✅ Tests already-converted WSL paths remain correct ✅ Tests mixed path separators (forward/backward slashes) ✅ Tests Entity.file_path construction doesn't create nested paths ✅ Includes parameterized tests for various path scenarios ✅ Includes integration tests with actual file operations
The test suite specifically checks for the bug described in issue #243 where paths like:
- Input:
C:\Users\Dr Brenda\basic-memory\housing\shadow-ln - Bug creates:
/mnt/c/Users/Dr Brenda/basic-memory/C:\Users\Dr Brenda\basic-memory\housing\shadow-ln - Should be:
/mnt/c/Users/Dr Brenda/basic-memory/housing/shadow-ln
Recommendation
Yes, we should keep these tests! They will:
- Document the expected behavior for WSL path handling
- Prevent regression if someone changes the path resolution code
- Help verify the fix when it's implemented
The tests are designed to pass once the bug is fixed, providing clear specifications for the correct behavior.
Branch: claude/issue-243-20250926-1447
Not a Bug - Documentation Issue
This is not a bug in Basic Memory. When running Basic Memory in WSL, you must use POSIX-style paths, not Windows-style paths.
The Issue
You're passing a Windows path to Basic Memory while running in WSL:
basic-memory project add shadow-ln "C:\Users\Dr Brenda\basic-memory\housing\shadow-ln"
The Solution
Use the WSL/POSIX path format instead:
basic-memory project add shadow-ln "/mnt/c/Users/Dr Brenda/basic-memory/housing/shadow-ln"
Why We Don't Support This
Basic Memory is a POSIX-first application. We don't add special handling for Windows-style paths in WSL because:
- WSL is a Linux environment - it expects POSIX paths
- Path handling would require complex hacks throughout the codebase wherever files are accessed
- This is the expected behavior - all Linux tools in WSL require POSIX paths
General Rule
When using Basic Memory:
- On Windows: Use Windows paths (
C:\Users\...) - In WSL/Linux: Use POSIX paths (
/mnt/c/users/...or/home/...) - On macOS: Use POSIX paths (
/Users/...)
Closing as "won't fix" - this is expected behavior for a POSIX-based application running in WSL.