Since a few days, I keep getting that message from VSCode. I normally have 2-3 instances of code open, sometimes more.
Visual Studio Code is unable to watch for file changes in this large workspace
I already increased my fs.inotify.max_user_watches limit to 524288.
cat /proc/sys/fs/inotify/max_user_watches gives me 524288 - I have already configured that years ago on my system and it always used to work.
I excluded a whole bunch of file from code's watcher settings:
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.git/*/**": true,
"**/node_modules/*/**": true,
"**/dist/*/**": true,
"**/tmp/*/**": true,
"**/.angular/*/**": true
}
There are no files that I can add to the exclusion, unless I would exclude actual source files which are under version control.
Running find . -type f | wc -l in the root of each of the projects I have open in VSCode gives me a number of ~100k for each project. So with 3 instances of VSCode open, I would still have a headroom of about 200k files (plus the exclusions above)
I found [this script] in another SO thread. Executing it at different times, I found out:
- With no VSCode instance open, I only have ~400 watches
- When I open the first VSCode instance, it quickly goes up to above 200k. (But as I wrote above, the folder I opened only has arount 100k files, including node_modules, .git, etc). So that means that some files seem to be watched twice by vscode
- Logically, when I open a second instance of VSCode, watches go up above 400k, so with the third instance, it reaches the limit and gives me the error
Confusingly, the watcherExclude setting I wrote above seems to be ineffective. Wether I set it or not, both scenario lead to the same amount of watches and to the error message when I open the third instance of vscode.
My computer is quite well equipped. I got a bunch of RAM and disk space, and I just double checked that the disk is not full (about 200GB free space), so that can't be the problem either.
To me, it looks like there may be a bug in VSCode, or maybe in an extension that I use.
Is there any way how to find out, which files are actually being watched?