VSC unable to watch for file changes in this large workspace weird
The solution I found and it's work for me is
add this line fs.inotify.max_user_watches=524288
in to /etc/sysctl.conf
and then run the command sudo sysctl -p
and then go to your vscode settings find a file called settings.json
and this line to it
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
}
you can also refer this link https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
The fact that you are out of watches does not mean that its VSCode
's fault.
VSCode
has for sure issues with excluding directories from watch (on linux) (update: most are recently resolved here, and here)
But since you have counted the files yourself, the error message in this case is probably misleading and some other application has already exhausted watches.
To trace the guilty app you can use this nice script
what linux ppl dont know, there are ppl new to linux like me. So if you're a noob, this is for you.
- Open a new
terminal
. cat /proc/sys/fs/inotify/max_user_watches
(might be a number 8k+)
now (a)
for vim
-Editor
- (a)
sudo vim /etc/sysctl.conf
- (a) go all the way down and add a new line with:
fs.inotify.max_user_watches=524288
(make sure you DONT have a#
in front of the command) - (a) type
:wq!
and press enter
or (b)
for nano
-Editor (thanks to @bradrar)
(b)
sudo nano /etc/sysctl.conf
(b) go all the way down and add a new line with:
fs.inotify.max_user_watches=524288
(make sure you DONT have a#
in front of the command)- (b) type ctrl + x, type y and press enter
- type
sudo sysctl -p
- type again:
cat /proc/sys/fs/inotify/max_user_watches
(should be 500k+ now) - (thank me later.)