Bug: edit_file and file operations fail silently in .cursor/rules directory

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:

  1. The edit_file function fails silently when targeting files in .cursor/rules/
  2. File copy operations to .cursor/rules/ create empty files

Steps to reproduce

  1. 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
  1. 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

  1. Use Cursor settings UI to create/edit rules
  2. Write files to a different location then manually copy
  3. Use symbolic links from writable locations
  4. 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:

  1. Create a directory for global rules:
mkdir -p ~/.cursor/rules/cursor-known-issues
  1. 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
""")
  1. 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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.