191.2 Bugfix Git Emfile Too Many Open Files Quick Fix

Documentation for Sessions

Quick Fix: Git EMFILE "Too Many Open Files"

Session: 191.2
Date: 2026-03-09
Status: Fix for Git failures in VSCode/Cursor


The Problem

Git operations fail with:

EMFILE: too many open files, open '/Users/.../gspace1/.git/HEAD'
EMFILE: too many open files, open '/Users/.../gspace1/.git/config'

Root cause: macOS default file descriptor limit is 256, which is too low for multi-monorepo + Cursor + Git + file watchers.


Fix A: Launch Cursor with High Limits (Most Reliable)

Cursor launched from Dock/Spotlight may not inherit launchctl limits. Use the launcher script:

# From Terminal - opens Cursor with ulimit 65536
./tools/scripts/monorepo-scripts/start-cursor-with-limits.sh

# Or open a specific folder
./tools/scripts/monorepo-scripts/start-cursor-with-limits.sh ~/developer/repos-gspace/gspace1

Or use the yarn script (from project root):

yarn cursor

Optional: Add alias in ~/.zshrc:

alias cursor='~/developer/repos-gspace/gspace1/tools/scripts/monorepo-scripts/start-cursor-with-limits.sh'

Fix B: System-Wide Limits (Requires Restart)

# 1. Apply system limits (requires password)
sudo launchctl limit maxfiles 65536 200000

# 2. Verify
launchctl limit maxfiles
# Expected: maxfiles    65536          200000

# 3. Restart Cursor completely (⌘ + Q, wait 10s, reopen)

If Limits Reset After Reboot

Your LaunchAgent exists at ~/Library/LaunchAgents/limit.maxfiles.plist. Reload it:

launchctl unload -w ~/Library/LaunchAgents/limit.maxfiles.plist
launchctl load -w ~/Library/LaunchAgents/limit.maxfiles.plist

Workspace Settings (Already Applied)

Reduces Git and file watcher load. In .vscode/settings.json:


Other Git Log Warnings (Non-Critical)

Warning Cause Action
GitFileSystemProvider: File not found for .env.local File is gitignored/untracked Ignore
no upstream configured for branch session-XXX Session branches are local-only Normal for SAGP
git blame: no such path .env.local File not in that commit Ignore

Full docs: FIX-FILE-LIMITS.md