Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is causing the Listen error in rails app

So I did some changes in the schema.rb file and as far as I think, that is what caused this error. Also I think I deleted some migration files improperly.

FATAL: Listen error: unable to monitor directories for changes.

Its coming on every rails command I use on the terminal

I have seen this as the solution everywhere

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

But I don't get what it does. Could someone explain what is going on here. As in what is the solution doing and what actually caused this error.

like image 771
Jayanti Hari Avatar asked Oct 26 '25 08:10

Jayanti Hari


1 Answers

Read the about inotify: inotify man page

The inotify API provides a mechanism for monitoring file system events. Inotify can be used to monitor individual files, or to monitor directories. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory.

It's not uncommon to encounter a system limit on the number of files you can monitor.

You can get your current inotify file watch limit by executing:

$ cat /proc/sys/fs/inotify/max_user_watches

/proc/sys/fs/inotify/max_user_watches

This specifies an upper limit on the number of watches that can be created per real user ID.

When this limit is not enough to monitor all files inside a directory, the limit must be increased.

You can set a new limit temporary with:

$ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p

If you like to make your limit permanent, use:

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

The gem listen has ran into this limit, so you'll need to increase you it...

Listen gem wiki

like image 185
iamcaleberic Avatar answered Oct 28 '25 22:10

iamcaleberic