Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listen error: unable to monitor directories for changes

I am getting the following error while running my rails app in Ubuntu server

FATAL: Listen error: unable to monitor directories for changes. Visit https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers for info on how to fix this.

I have followed the above GitHub page, but I was unable to write in max_user_watches which were set in 8192 and I want to set that to 524288. in cat /proc/sys/fs/inotify/max_user_watches the file was in only read mode.I tried to grant write permissions, but I was getting permission denied error even with root access.

Thanks in Advance!!!

like image 815
current_user Avatar asked Feb 14 '17 12:02

current_user


People also ask

How do I ignore certain directories in Listen Listen?

Listen ignores some directories and extensions by default (See DEFAULT_IGNORED_FILES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer). You can add ignoring patterns with the ignore option/method or overwrite default with ignore! option/method. Note: :ignore regexp patterns are evaluated against relative paths.

How do I report changes to the listened-to directories?

Changes to the listened-to directories are reported by the listener thread in a callback. The callback receives three array parameters: modified, added and removed, in that order. Each of these three is always an array with 0 or more entries. Each array entry is an absolute path. Listeners can also be easily paused and later un-paused with start:

How do I only listen to a specific type of file?

Listen watches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just .rb extension), you should use the only option/method. Note: :only regexp patterns are evaluated only against relative file paths.


Video Answer


1 Answers

1000 is way too small, try with 524288 as explained in the wiki page: https://github.com/guard/listen/blob/master/README.md#increasing-the-amount-of-inotify-watchers

Listen uses inotify by default on Linux to monitor directories for changes. It's not uncommon to encounter a system limit on the number of files you can monitor. For example, Ubuntu Lucid's (64bit) inotify limit is set to 8192.

and

If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p 

If you are running ArchLinux, run the following command instead

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system 
like image 163
Mayur Shah Avatar answered Oct 06 '22 08:10

Mayur Shah