[Bug] Misleading error message hides permission error and suggests harmful system-wide file descriptor limit
Bug Description
Startup error suggests a dangerous system-wide fix for an unrelated error
Version: Claude Code 2.1.291 (Homebrew cask claude-code@latest, auto-updated from 2.1.290 minutes earlier), macOS 27.0.1 (26A434), MacBook Air M5, iTerm2 3.7.3
What happened:
The working directory (~/Documents/Claude) became unreadable to the shell. ls -al there returned "ls: .: Operation not permitted" (macOS privacy/TCC protection on the Documents folder). Starting claude in that folder printed:
error: An unknown error occurred, possibly due to low max file descriptors (Unexpected)
Current limit: 256
To fix this, try running:
ulimit -n 2147483646
If that still doesn't work, you may need to run:
sudo launchctl limit maxfiles 2147483646
Following both suggestions did not fix it (still "An unknown error occurred (Unexpected)"). The launchctl command applies system-wide until reboot. After it, newly started terminals (iTerm2 and Terminal) hung, so the only way out was a restart. The Mac then would not boot and macOS had to be reinstalled from Recovery. I can't prove the failed boot came from this, but the hangs started right after the launchctl command.
Problems:
1. The real error (EPERM on the working directory) is hidden behind "unknown error"; the message should show the underlying errno/path.
2. The file-descriptor guess is shown because the limit is 256, not because a file-descriptor error happened.
3. Recommending sudo launchctl limit maxfiles 2147483646 is harmful: a near-2^31 limit applied system-wide makes programs that close every possible descriptor before starting a child process loop for a very long time, which looks like a hang. If a limit hint is kept, it should be a modest per-shell value (e.g. ulimit -n 65536) and never a system-wide launchctl change.
Expected: Claude reports "cannot read working directory: Operation not permitted" and points to System Settings → Privacy & Security → Files & Folders.
Environment Info
- Platform: darwin
- Terminal: iTerm.app
- Version: 2.1.291
- Feedback ID: 28582a30-45ee-497d-a57b-036098342526