Dive Deeper and Set Inotify by Hand

Overview

On Linux, file system monitoring relies on the Inotify facility. Inotify requires a watch handle for each directory being monitored. For intelligent IDEs like IntelliJ, VSCode, and Thorg, detecting external file changes is essential for knowing the state of files of interest.

Troubleshooting

There are couple of different inotify limits that you might need to increase. The following script can help you figure out which limit you are breaching.

If you ran into inotify issues and want to find out which inotify limit you are running low on you can start with just checking your current limits, with the simple command in bash:

sysctl fs.inotify.max_user_watches; \
sysctl fs.inotify.max_user_instances; \
sysctl fs.inotify.max_queued_events

This should print output that contains something like:

fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 256
fs.inotify.max_queued_events = 16384

If you want to get the actual limits used, that is not as straightforward and requires some scripting. You can see some options here, (Also remember Remember to Review Scripts from Internet Prior to Running Them)

After running the above script you can adjust your limits by editing your system inotify configuration values:

Increase Inotify Limits

One-liner using heredoc:

sudo tee /etc/sysctl.d/99-inotify.conf > /dev/null <<'EOF'
# Inotify limits for file watching
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 256
fs.inotify.max_queued_events = 16384
EOF
OR use your editor of choice to edit config file

You can use your CLI editor of choice vi/nano/... and edit the /etc/sysctl.d/99-inotify.conf file new limits like the following: (or )

fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 256
fs.inotify.max_queued_events = 16384

Apply the changes:

sudo sysctl -p /etc/sysctl.d/99-inotify.conf

Verify it worked:

sysctl fs.inotify.max_user_watches; \
sysctl fs.inotify.max_user_instances; \
sysctl fs.inotify.max_queued_events

References


Backlinks