Repository navigation
Closed as duplicate
Description
Basic Memory MCP Server - .gitignore Bug Report
Summary
The basic_memory MCP server fails to respect .gitignore patterns and attempts to sync build artifacts, causing sync failures on Rust projects with complex incremental compilation filenames.
Bug Description
Expected Behavior
The basic_memory MCP server should:
- Read and respect all patterns in the project's
.gitignorefile - Skip directories and files that match
.gitignorepatterns - Never attempt to sync build artifacts (e.g.,
target/,node_modules/,dist/,build/) - Handle complex filenames gracefully without crashing
Actual Behavior
The server:
- Attempts to sync files in
backend/target/despite it being in.gitignore - Fails with file move errors on Rust's incremental compilation artifacts
- Reports sync failures that block other operations
Error Message
❌ Sync failed for project 'ai-robot-security': Cannot move entity from
'backend/target/debug/incremental/angel_security-3jhmxh0kgxo7h/s-hadf7wssc0-1pd28gt-2u4rvv79i4alxt84s5c72zkiy/5w0grk96adxa0x4j2z8bqoffm.o' to
'backend/target/debug/deps/angel_security-db91db90048569b2.5w0grk96adxa0x4j2z8bqoffm.rcgu.o':
destination path is already occupied by another file.
Reproduction Steps
- Create a Rust project with basic_memory configured
- Add
backend/target/to.gitignore(ortarget/for a standard Rust project) - Run
cargo buildto generate build artifacts - Attempt to sync with basic_memory
- Observe sync failure on incremental compilation files
Project Structure
/Users/au/Documents/idea_AI_robot_drone_security/
├── .gitignore (contains "backend/target/" on line 8)
├── backend/
│ ├── Cargo.toml
│ ├── src/
│ └── target/ # ← Should be ignored but isn't
│ └── debug/
│ ├── incremental/
│ └── deps/
├── frontend/
└── memory-bank/
.gitignore Content (Relevant Lines)
# Rust Backend
backend/target/
backend/Cargo.lock
backend/**/*.rs.bk
backend/**/*.pdbRoot Cause Analysis
Primary Issues:
-
Gitignore Parsing: The server is not properly parsing or applying
.gitignorepatterns- Pattern
backend/target/should exclude the entire directory - The server is still attempting to process files within this directory
- Pattern
-
File Naming Conflicts: Rust's incremental compilation creates files with:
- Long hash-based names (e.g.,
5w0grk96adxa0x4j2z8bqoffm.o) - Similar names in different directories
- Multiple files with the same base name but different paths
- The server's file moving/renaming logic can't handle these edge cases
- Long hash-based names (e.g.,
-
Missing Default Exclusions: The server should have built-in exclusions for common build directories:
target/(Rust)node_modules/(Node.js)dist/,build/(Various build systems)*.o,*.so,*.dll(Compiled objects)
Suggested Fixes
1. Properly Implement .gitignore Support
# Pseudocode for proper gitignore handling
import pathspec # or similar gitignore parsing library
def should_sync_file(file_path, project_root):
gitignore_path = os.path.join(project_root, '.gitignore')
if os.path.exists(gitignore_path):
with open(gitignore_path) as f:
spec = pathspec.PathSpec.from_lines('gitwildmatch', f)
# Check if file matches any gitignore pattern
relative_path = os.path.relpath(file_path, project_root)
if spec.match_file(relative_path):
return False # Skip this file
return True2. Add Default Exclusions
DEFAULT_EXCLUSIONS = [
'target/', # Rust
'node_modules/', # Node.js
'dist/', # Build output
'build/', # Build output
'.git/', # Git directory
'*.o', # Object files
'*.so', # Shared libraries
'*.dll', # Windows libraries
'*.pyc', # Python bytecode
'__pycache__/', # Python cache
]3. Handle Complex Filenames Gracefully
- Don't attempt to move/rename files during sync
- Use content hashing instead of filename-based deduplication
- Handle Unicode and special characters properly
- Implement proper error recovery instead of failing entire sync
4. Add Configuration Option
Allow users to manually specify exclusions in basic_memory config:
{
"projects": {
"ai-robot-security": {
"path": "/Users/au/Documents/idea_AI_robot_drone_security",
"exclude": [
"backend/target/**",
"frontend/node_modules/**",
"**/*.o"
]
}
}
}Impact
- Severity: High - Blocks sync for any Rust project
- Affected Users: Anyone using basic_memory with compiled languages (Rust, C++, Go, etc.)
- Workaround: Delete build artifacts before sync (not practical)
Test Cases
- Create a Rust project with
target/in.gitignore→ Should not sync any files intarget/ - Create files with complex names containing hashes → Should handle gracefully
- Add custom patterns to
.gitignore→ Should respect all patterns - Use nested
.gitignorefiles → Should respect hierarchy - Test with symlinks in ignored directories → Should not follow symlinks in ignored paths
Environment
- OS: macOS (Darwin)
- Basic Memory Version: (current MCP server version)
- Project Type: Rust + TypeScript/React
- File System: APFS (case-insensitive)
Additional Notes
- The sync fails consistently on the same files
- The error suggests the server is trying to move/rename files during sync (why?)
- Other projects without build artifacts sync successfully
- The server continues to work partially (can read/write notes) despite sync failures
Activity
phernandez commentedon Sep 26, 2025
marking as a dup of #287