entr(1)

Run arbitrary commands when files change

project page

kqueue(2) on BSD and Mac requires one file descriptor for each file and directory under watch. This poses a problem when watching a large code base since the default limit imposed by some operating systems is not very high.

Use the following instructions to set a default that is more reasonable for your use case. For simplicity, we assume that a reboot after changing configuration.

BSD

Modify /etc/login.conf

staff:\
:openfiles-max=16384:\
:openfiles-cur=4096:\

Mac

Install a new property list file

cd /Library/LaunchDaemons
sudo curl -sO https://eradman.com/entrproject/etc/limit.maxfiles.plist

Verify the content of this file using

shasum limit.maxfiles.plist
5c932adc5412d1da93ac68c930085d2b2e9c27df  limit.maxfiles.plist

Linux

The maximum number of inotify watches may be set by setting the max_user_watches sysctl

cat /proc/sys/fs/inotify/max_user_watches

Make changes permanent by adding a file to /etc/sysctl.d/.

entr =< 4.3

Prior to the 4.4 release, entr required one file descriptor for each file under watch. To raise this limit, edit /etc/security/limits.conf

*       hard    nofile  16384
*       soft    nofile  16384