-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Bug Report: write_to_file Tool ENOENT Error
Problem Description
The write_to_file tool in the Roo-Cline VS Code extension (version 3.34.5) throws ENOENT (No such file or directory) errors when attempting to create files in non-existent subdirectories. The issue occurs in the handlePartial method of the DBr class.
Root Cause
The handlePartial method attempts to check if a file exists using ci(A) (file existence check) before ensuring parent directories exist. When creating files in new subdirectories, this check fails with ENOENT because the parent directories don't exist yet.
Problematic Code (line ~5966):
c=await ci(A),e.diffViewProvider.editType=c?"modify":"create"Solution Applied
Wrapped the file existence check in a try-catch block that creates parent directories recursively when the check fails.
Fixed Code:
try{c=await ci(A)}catch{let D=gAe.default.dirname(A);try{await HLe.default.mkdir(D,{recursive:!0})}catch{}c=!1}e.diffViewProvider.editType=c?"modify":"create"Fix Details
- File Modified:
/home/mts/.vscode-oss/extensions/rooveterinaryinc.roo-cline-3.34.5-universal/dist/extension.js - Method Fixed:
DBr.handlePartial - Line Number: ~5966
Testing Results
The fix was successfully tested with multiple scenarios:
- ✅ Creating files in simple subdirectories (
test_subdir/test_file.txt) - ✅ Creating files in deeply nested directories (
deep/nested/subdirectory/test1.txt) - ✅ Creating files in directories with special characters (
test-dir_with-special.chars/test2.txt) - ✅ Creating files in directories with spaces (
level 1/level 2/level 3/test3.txt)
All test cases completed successfully without ENOENT errors.
Technical Implementation
The fix uses:
- Try-catch wrapper around file existence check
- Recursive directory creation with
mkdir(D, {recursive:!0}) - Proper error handling for directory creation failures
- Maintains existing edit type logic for existing vs new files
Impact
This fix resolves a critical usability issue where AI assistants could not create files in new subdirectories, significantly improving the tool's reliability for complex file operations.
Labels
bug, enhancement, tools, file-system
Metadata
Metadata
Assignees
Labels
Type
Projects
Status