Too Many Open Files

Ben Simon has a post about a problem that can come up with Emacs running on macOS. The problem is that Emacs will report “too many open files” when attempting to open a file. It turned out to be a hard problem to solve.

Simon tried all sorts of ways to increase the limit of open files but nothing worked. Finally, he discovered a post by another person suffering from the problem. It turns out that you can run file-notify-rm-all-watches to inhibit the error. That seemed easy enough but when he tried, he found that the function didn’t exist. After some Googling, he found the code for the function and added it to his configuration. After that, he could recover from the error by simply running the function.

I’m running the latest official release (28.1) and file-notify-rm-all-watches isn’t defined for my Emacs either. It is, however, in the latest version of filenotify.el that has been merged into the Emacs28 branch of the git repository. Doubtless, it will be available in the next release. In the meantime, you can simply add it yourself as Simon did. It’s only 7 lines so it’s an easy addition.

I’ve never encountered this error and that’s probably true for most of you. If you have encountered it, this fix is much easier than having to restart Emacs.

This entry was posted in General and tagged . Bookmark the permalink.