inotify errors trying to compile Ionic/Angular app

I'm trying to make an Ionic mobile app with Angular, and running the start script, my terminal is flooded with this:

[ng] Error from chokidar (/home/ben/Nextcloud/codn/FH-Cross-Platform/Whiteout/Whiteout/node_modules/ionicons/dist/ionicons/svg): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/ben/Nextcloud/codn/FH-Cross-Platform/Whiteout/Whiteout/node_modules/ionicons/dist/ionicons/svg/resize-sharp.svg' of these errors for each file in the folder!

I've found the inotify problem description and standard fix for this, but it doesn't work for me:

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

I still get the error. What confuses me a bit is that the error is about file watchers, but the solution deals with user watchers. However, it was suggested to work for this issue here, here and here.

Problem seems to exist for React as well:

I dealt with this a couple of years back and using the value 1048576 for the user watches and installing the watchman package solved it for me.

1 Like

Any specific reason why this exact value does the trick?

I can't remember anymore - I think the issue originated in JetBrains WebStorm being slow - complaining on not enough user watches.

After some trial and error and a lot of search-fu I ended up with this value.

I later found that watchman increased the responsiveness - which is why I ended up using the two.

I'm using PHPStorm, and indeed there was one annyoing little bubble saying sth. about inotify but I ignored it because I didn't understand.
Anyhow, what on earth does the IDE have to do with it, I mean how does it affect the running of the code if I edit it with a different program?

When you are using a live preview - the system needs to know when files has changed.

The defaults need adjustment for the system to reliable execute some tasks.

A development environment where you are using live reload needs a lot of file watchers. Specifically when you are using node - with live reload.

1 Like

This works!
Fun fact, if you run the aforementioned commands echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system where /etc/sysctl.d/40-max-user-watches.conf already exists, a /etc/sysctl.d/50-max-user-watches.conf is created and max_user_watches set to 16384, because this happens:

$ echo fs.inotify.max_user_watches=1048576 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
* /usr/lib/sysctl.d/10-manjaro.conf wird angewendet …
fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 524288
* /etc/sysctl.d/40-max-user-watches.conf wird angewendet …
fs.inotify.max_user_watches = 1048576
* /usr/lib/sysctl.d/50-coredump.conf wird angewendet …
kernel.core_pattern = |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h
* /usr/lib/sysctl.d/50-default.conf wird angewendet …
kernel.sysrq = 16
kernel.core_uses_pid = 1
net.ipv4.conf.default.rp_filter = 2
sysctl: Schlüssel »net.ipv4.conf.all.rp_filter« wird gesetzt: Das Argument ist ungültig
net.ipv4.conf.default.accept_source_route = 0
sysctl: Schlüssel »net.ipv4.conf.all.accept_source_route« wird gesetzt: Das Argument ist ungültig
net.ipv4.conf.default.promote_secondaries = 1
sysctl: Schlüssel »net.ipv4.conf.all.promote_secondaries« wird gesetzt: Das Argument ist ungültig
net.ipv4.ping_group_range = 0 2147483647
net.core.default_qdisc = fq_codel
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
fs.protected_regular = 1
fs.protected_fifos = 1
* /etc/sysctl.d/50-max_user_watches.conf wird angewendet …
fs.inotify.max_user_watches = 16384
* /usr/lib/sysctl.d/50-pid-max.conf wird angewendet …
kernel.pid_max = 4194304

I had to delete /etc/sysctl.d/50-max-user-watches.conf and reboot, then it worked.

Okay, now I understand why this variable makes a difference for live preview (also found this link to Jetbrains docs where it's explained: - but it shouldn't actually be the IDE that makes this difference, because it's the ionic development server that produces the ENOSPC error and runs into this limit (well, maybe both the server and the IDE would). Anywho, the error comes up before I start PHPStorm.

Config files in .d folders are loaded in alfa-numeric order.

If the same property is defined in multiple files - the last read config takes precedence.

1 Like

Just to be sure: You actually used Watchman and tweaked some system settings, or just installing it already helped?

user on another post got a longer explanation about running out of inotify watches in error message related to an audio problem

Pulseaudio not working after updating kernel

[pulseaudio] module-udev-detect.c: You apparently ran out of inotify watches, probably because Tracker/Beagle took them all away.I wished people would do their homework first and fix inotify before using it for watching whole directory trees which is something the current inotify is certainly not useful for. Please make sure to drop the Tracker/Beagle guys a line complaining about their broken use of inotify

if terminal is flooded with an error for each file in folder how many files are in the folder?

Yes - watchman is an inotify helper - invaluable if you ask me.

When dealing with development using node.js you are dealing with a foldertree with 100's of folders and 1000's of files and a folder structure so deep that - if working on Windows - the Windows chokes on it when you want to remove it (not NTFS it self but Windows (max path length of 254 chars)).

So yes - so upping the bar for inotify - from 16384 - until the system no longer chokes is a must.

1 Like

Haven't actually done anything with Watchman yet, just installed (because the mere installation of a specific package has fixed things for me quite a few times in the past) :sweat_smile:
But just upping that max_watches limit to over a million lets me do this lil' program at least

:man_facepalming: Why aren't any of the 90% of my buddies running into this who develop on Windows (and why is this still Windows 10's default in this day and age?)?

Forum kindly sponsored by