Bug: edit_file and file operations fail silently in .cursor/rules directory
Description
Two related issues have been discovered with file operations in the .cursor/rules
directory:
- The
edit_file
function fails silently when targeting files in.cursor/rules/
- File copy operations to
.cursor/rules/
create empty files
Steps to reproduce
- Attempt to use
edit_file
to modify a file in.cursor/rules/
:
edit_file("~/.cursor/rules/my-rule.mdc", "content")
# File is either not created or created empty
- Try to copy files to
.cursor/rules/
:
cp existing-rule.mdc ~/.cursor/rules/
# Creates empty file
Expected behavior
edit_file
should successfully create/modify files in.cursor/rules/
- File copy operations should successfully copy content to
.cursor/rules/
- If operations cannot be performed, clear error messages should be provided
Actual behavior
- Operations fail silently
- Empty files are created
- No error messages or warnings are shown
- Content appears in chat history but is not written to files
Impact
- Users cannot programmatically manage Cursor rules
- Manual workarounds are required (UI, external editors)
- Affects rule maintenance and automation
- Particularly problematic for global rules that apply across projects
Current workarounds
- Use Cursor settings UI to create/edit rules
- Write files to a different location then manually copy
- Use symbolic links from writable locations
- Edit files with external editors
Environment
- Cursor Version: 0.46.10
- OS: macOS Sonoma 14.3.1
- Architecture: Apple M1
Related issues
- GitHub Issue #2827 “edit_file function doesn’t work for files in .cursor/rules/”
- Forum thread: “Cursor agent cannot write to .cursor/rules files”
Reproduction Example
I encountered this while trying to create global rules for known Cursor issues. Here’s a minimal reproduction:
- Create a directory for global rules:
mkdir -p ~/.cursor/rules/cursor-known-issues
- Try to create a rule file:
edit_file("~/.cursor/rules/cursor-known-issues/test-rule.mdc", """---
description: Test rule
globs: ["**/*"]
alwaysApply: true
global: true
---
# Test Rule
- Test content
""")
- Check the file:
cat ~/.cursor/rules/cursor-known-issues/test-rule.mdc
# File is empty
The same issue occurs with file copies and any other file operations targeting the .cursor/rules
directory.