Listen Error: Unable to Monitor Directories for Changes

Listen error: unable to monitor directories for changes

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

FATAL: Listen error: unable to monitor directories for changes

Just try to execute this from your console:

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

Hope this will work for you
.

References: click_here

What is causing the Listen error in rails app

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

Travis builds are failing with fatal listen error

If you're running this on TravisCI and a CI/staging/testing server, you should not need to watch files for changes. The code should be deployed to the server, and then bundle exec rails test should run and that's it. No file watching necessary.

What I suspect is that the config for your environment is not set up correctly and that listen gem is somehow activated for the testing environment when it should only be activated for the development environment.

Try running the tests locally with the same environment as TravisCI (testing in this example):

RAILS_ENV=testing bundle exec test

and see what it says. If it gives you that error, check the config/environments/testing.rb file and look for config.cache_classes.

When config.cache_classes is set to true, the classes are cached and the listen/file-watcher will not be active. In your local development environment, config/environments/development.rb, the config.cache_classes setting should be set to false so that file-watching and reloading happens.

Monitor Directory for Changes

Look at inotify.

With inotify you can watch a directory for file creation.

How can I monitor directories in vala?

To monitor a directory, you need to first create a GLib.File from that directory by using one of the GLib.File.new_* static methods. new_for_path is probably what you want.

You then need to create a GLib.FileMonitor for that directory using the monitor_directory method of the GLib.File object.

You can then connect to the changed signal of the GLib.FIleMonitor object.

When you compile, you will need to include --pkg gio-2.0.

Example:

void on_change () {
print("changed\n");
}

void main () {
GLib.File usr_share_applications = File.new_for_path(
"/usr/share/applications"
);
GLib.File local_share_applications = File.new_for_commandline_arg(
GLib.Environment.get_user_data_dir() + "/applications"
);

GLib.FileMonitor mon1;
GLib.FileMonitor mon2;

try {
mon1 = usr_share_applications.monitor_directory(
GLib.FileMonitorFlags.NONE
);
mon1.changed.connect(on_change);
print("Monitoring: "+usr_share_applications.get_path()+"\n");
} catch (GLib.Error e) {
print("Error: "+e.message+"\n");
}
try {
mon2 = local_share_applications.monitor_directory(
GLib.FileMonitorFlags.NONE
);
mon2.changed.connect(on_change);
print("Monitoring: "+local_share_applications.get_path()+"\n");
} catch (GLib.Error e) {
print("Error: "+e.message+"\n");
}

GLib.MainLoop loop = new GLib.MainLoop();
loop.run();
}

Error User limit of inotify watches reached. ExtReact build

Why?

Programs that sync files such as dropbox, git etc use inotify to notice changes to the file system. The limit can be see by -

cat /proc/sys/fs/inotify/max_user_watches

For me, it shows 100000. When this limit is not enough to monitor all files inside a directory it throws this error.


Increasing the amount of inotify watchers(Short version):

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 (see here for why):

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

Then paste it in your terminal and press on enter to run it.


Technical details:

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.

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

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

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

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

You may also need to pay attention to the values of max_queued_events and max_user_instances if Listen keeps on complaining.

Source: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers



Related Topics



Leave a reply



Submit