rb-inotify: Too many open files - Failed to initialize inotify: the user limit on the total number of inotify instances has been reached.

Every now and then [guard] fails to start with the following message:

11:21:41 - INFO - Guard is now watching at ‘/home/cordawyn/Projects/test’ /home/cordawyn/.rvm/gems/ruby-1.9.3-p327-turbo/gems/rb-inotify-0.8.8/lib/rb-inotify/notifier.rb:66:in `initialize’: Too many open files - Failed to initialize inotify: the user limit on the total number of inotify instances has been reached. (Errno::EMFILE)

This happens after returning the computer (notebook) from sleep mode, then launching guard (on a Rails project). To make things worse, it is not 100% reproducible (I’d say, around 80% of attempts).

I figure this might not be exactly rb-notify’s bug, but rather that of either inotify or a million other kernel subsystems, but guard+rb-notify seems to be the only combo that manages to surface this issue. If you could point me to a more appropriate responsible party, it would be much appreciated 😉

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I’ve just stumbled upon the same problem. I think this issue could be not relate to rb-inotify, but the tools we use on our computers. I just tried to increase a limit of user instances. Here is the link with more info:

http://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached

I had to increase this:

echo 256 > /proc/sys/fs/inotify/max_user_instances

yup, that solves my issues

# increase inotify file watch limit
ofile=/proc/sys/fs/inotify/max_user_instances
sudo sh -c "echo 8192 > $ofile"
cat $ofile
rerun app.rb

thanks @hron it solved the issue for me