File watcher ignores .gitignore, can exhaust system-wide file descriptors on macOS

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor’s file watcher monitors all files in the workspace regardless of
.gitignore, .cursorignore, or .cursorindexingignore. When a
gitignored directory contains a large number of files (e.g., test output
with millions of files), the file watcher exhausts the system-wide file
descriptor limit (kern.maxfiles) on macOS, causing ENFILE (too many
open files) errors for all processes on the system, not just Cursor.
Even ps and lsof in a separate terminal fail with “too many open
files”.

Steps to Reproduce

  1. Create a gitignored directory in the workspace containing a large
    number of files (e.g., test/out/ with 2M+ files from stress test
    runs)
  2. Open the workspace in Cursor
  3. Observe system-wide ENFILE errors in all terminals

Expected Behavior

The file watcher should respect .gitignore (similar to how search.useIgnoreFiles works for search). A single application should not be able to starve the entire system of file descriptors.

Operating System

MacOS

Version Information

Version: 2.6.20 (Universal)
VSCode Version: 1.105.1
Commit: b29eb4ee5f9f6d1cb2afbc09070198d3ea6ad760
Date: 2026-03-17T01:50:02.404Z
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.3.0

Additional Information

Why keep test results in the workspace?

The tests results are useful for AI analysis. AI agent can search and analyze the results without special permissions.

Size example:

% tree ~/tmp/out | tail -1 
354963 directories, 1768911 files

Workaround - set files.watcherExclude

Add files.watcherExclude to .vscode/settings.json:

{
    "files.watcherExclude": {
        "**/test/out/**": true
    }
}

Workaround - don’t keep lot of files in the workspace

Move the files outside of the workapspace. Allow AI agent to access the directory with the tests results.

Does this stop you from using Cursor

Yes - Cursor is unusable

Thanks for the detailed report!

There’s a long-standing VS Code issue requesting this. I can’t speak for that team, but I think the file watcher and .gitignore serve two different purposes. .gitignore tells git what not to track, but the editor still needs to watch many Git-ignored paths (e.g., keeping the explorer tree in sync, detecting external changes to open files, powering extension file watchers).

For your setup, files.watcherExclude is a really good workaround.

Agreed, that’s something we can look at improving! Will pass it onto the team.

It seems that Cursor try to watch all directories in the workspace without limit, instead of all entities displayed by the explorer.

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