Ray's Knowledge Base

eglot freezes Emacs when a language server asks to watch files outside any version-control root

PitfallVerified 27 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

Emacs stops answering (even emacsclient -e and the backtrace signal get no reply) soon after opening a Python file that is in no git repository. A find -H ... process runs over a huge folder, often the home folder.

Cause#

With no VCS root, the project falls back to the file's folder or a parent such as ~. pyright asks the client to watch the project's files (workspace/didChangeWatchedFiles), and eglot answers by listing every file in the project first. Outside git it lists with find, synchronously, so Emacs waits until find has walked the whole tree. In a git repository eglot lists with git ls-files, which is fast.

Fix#

Kill the find process by its PID to get Emacs back. Then do not set up file watching when the project has no VCS root, for example by advising eglot's watch registration to do nothing unless (project-current) is a VC project. The only cost: in a loose folder the server does not see files changed outside Emacs. Git repositories keep watching.

Evidence#

  • Emacs 30 on macOS with eglot and pyright, 2026-09-26: a Python file under the home folder froze the daemon until the find was killed.
  • After the fix: a Python file in a plain folder with 20,000 files kept Emacs answering, with no find and no watches; a file in a git repository still got 1 watch and Emacs answered twice in a row.