vscode: Unable to watch for file changes in this large workspace - not a large workspace.

  • VSCode Version: 1.27.2
  • OS Version: Ubuntu 18.04 bionic (x86-64)

Steps to Reproduce:

  1. Create a basic web project with a node_modules directory which exceeds the limit of file watchers:
  2. Recursively count the number of files in the entire project directory using find . -type f | wc -l
  3. My project has 44452 files (including directories).
  4. Check current limit of file watchers using cat /proc/sys/fs/inotify/max_user_watches
  5. Make a note of the watcher limit of 8192
  6. Configure Visual Studio code to exclude the node_modules directory using
"files.watcherExclude": {
  "**/node_modules/**": true
}
  1. Count files in only node_modules using find node_modules -type f | wc -l
  2. Make a note of the file count: 43218
  3. Subtract the node_modules file count (43218) from project file count (44452)
  4. 44452 - 43218 = 1234
  5. 1234 is well within the watcher limit of 8192.
  6. If VS Code honours watcherExclude, it must only watch 1234 files.
  7. VS Code still complains it’s “Unable to watch for file changes in this large workspace”.

Does this issue occur when all extensions are disabled?: Yes

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 19
  • Comments: 45 (11 by maintainers)

Most upvoted comments

Same here too. VS Code 1.30.1 and only 41 files outside node_modules folder.

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@bpasero If you don’t mind my asking, what more information is needed for this issue?

Just a follow up on this, I have a project with 104 files where Code is configured to ignore node_modules and some other directories and I am seeing this usage:

   INOTIFY
   WATCHER
    COUNT     PID     CMD
----------------------------------------
    4541     5167  /usr/share/code/code /usr/share/code/resources/app/out/bootstrap-fork --type=watcherService
    4367     5189  /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProje
    4251     5231  /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTy

Holy smokes! That’s a lot of file watchers for 104 files. Clearly, this editor is not intended for large projects.

Confirming similar issue in Ubuntu 18.04. And when I had VSCode running I couldn’t start my webpack dev server because there were no available watchers. I had to kill VSCode and work from Sublime Text to continue working.

I just ran into this issue as well, and it’s rather annoying because I use watchers for other things like compiling latex. I am not sure this is a factor, but it is possible that another development tool (eg. webpack) is using up resources.

Hi @bpasero – sorry for the radio silence. I will run chokidar and test it out for you. Just been crazy busy lately. I hope to get to this by the weekend. Thanks for the help.

Still happens when no app is running. For more context, this is a fresh install of Linux Mint 19.2. So not only is there not another app running, there are barely any other apps installed. I was running Mint 17.3 for a long time (Ubuntu 14.04 equivalent) with VSCode and had no issues (never changed the amount of watchers). Yesterday I performed a completely fresh install of Mint 19.2 and VSCode was one of the first things I installed and I see the warning every time, even with only 4 files. Also, to answer your other question, I haven’t changed my configured limit, so it’s at the default value of 8192. But that should handle 4 files just fine. Also, as I mentioned, I never had to change that configuration when I was on Mint 17.3 and I habitually had 6+ apps running at the same time as VSCode. Seems like every Linux person on this thread who is reporting OS version is either Mint 19 or Ubuntu 18. Do you guys at MS have a machine with one of those versions to see if you can reproduce?

Same issue for me as well on Ubuntu 18.04.

Version: 1.31.1 Commit: 1b8e8302e405050205e69b59abb3559592bb9e60 Date: 2019-02-12T02:19:29.629Z Electron: 3.1.2 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Linux x64 4.18.0-15-generic

I ran the commands @jackwootton posted with some modifications. At first, I wasn’t getting any results back from running the command (same as @jackwootton). After some tinkering, I realized I needed to change the awk pattern from /anon_inode/ to /a_inode/ and finally got some results.

Commands I ran:

sudo lsof -e /run/user/1000/doc -e /run/user/1000/gvfs -nP | awk '/a_inode/ { gsub(/[urw]$/,"",$4); print "/proc/"$2"/fdinfo/"$4; }' | while read fdi; do count=$(sudo grep -c inotify $fdi); exe=$(sudo readlink $(dirname $(dirname $fdi))/exe); echo -e $count"\t"$fdi"\t"$exe; done | sort -nr > watches

Results:

4565    /proc/4679/fdinfo/21    /usr/share/code/code
3301    /proc/4719/fdinfo/20    /usr/share/code/code
96      /proc/1/fdinfo/6        /lib/systemd/systemd
72      /proc/2313/fdinfo/11    /usr/lib/gnome-settings-daemon/gsd-xsettings

... omitted for brevity

So, it appears vscode has launched two processes - the first (4679) having 4565 inotify monitored files and the second (4719) having 3301 inotify monitored files. My project only contains ~30 files.

Just to be sure, I disabled all the extensions, shut down vscode, and re-ran the above commands - no vscode processes where found, as expected.

I then relaunched vscode, leaving the extensions disabled, and opened my project folder again. I added an empty .js file and immediately received the ‘unable to watch for file changes’ warning. I then re-ran the above commands and got a similar result to the first run:

4565    /proc/12867/fdinfo/21   /usr/share/code/code
3298    /proc/12948/fdinfo/20   /usr/share/code/code
96      /proc/1/fdinfo/6        /lib/systemd/systemd
72      /proc/2313/fdinfo/11    /usr/lib/gnome-settings-daemon/gsd-xsettings

... omitted for brevity

And just to make sure things matched, I did a line count on /proc/12867/fdinfo/21 and it did indeed contain 4565 inotify entries. Here’s a sample:

pos:    0
flags:  02004000
mnt_id: 13
inotify wd:11d5 ino:1200674 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:74062001e79915b2
inotify wd:11d4 ino:c61680 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8016c60034d13d16
inotify wd:11d3 ino:c61696 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:9616c6006fb687e8
inotify wd:11d2 ino:c61689 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8916c600bf718bd9
inotify wd:11d1 ino:c616ae sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:ae16c600399e012c
inotify wd:11d0 ino:c616ab sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:ab16c600380d4a93
inotify wd:11cf ino:c616a5 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:a516c60081ca84bc
inotify wd:11ce ino:c6167f sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7f16c600b4a97fa4
inotify wd:11cd ino:c61697 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:9716c60081c875ca
inotify wd:11cc ino:c61695 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:9516c600615d2ded
inotify wd:11cb ino:c61694 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:9416c600305ec5a3
inotify wd:11ca ino:c61686 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8616c60085f0d0df
inotify wd:11c9 ino:c616eb sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:eb16c6004f0db028
inotify wd:11c8 ino:c61684 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8416c6009d9985d7
inotify wd:11c7 ino:c6168b sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8b16c6006f9705a9
inotify wd:11c6 ino:c61685 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8516c6005d9fb664
inotify wd:11c5 ino:c6168a sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8a16c600a56530fc
inotify wd:11c4 ino:c61688 sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:8816c600766d2ef5
inotify wd:11c3 ino:c616fe sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:fe16c600a6b4d755
inotify wd:11c2 ino:c60c0a sdev:800002 mask:fc6 ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:0a0cc600209c7eb5

... omitted for brevity

Also happening for me on Linux Mint 19.1 with a single folder and

Version: 1.31.1 Commit: 1b8e8302e405050205e69b59abb3559592bb9e60 Date: 2019-02-12T02:19:29.629Z Electron: 3.1.2 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Linux x64 4.15.0-45-generic

Could background compilation in watch mode be the culprit?

@pascollin This could be an effect of another editor or watch tool being open. e.g. sublime_text, webpack watch, cpx e.t.c There is a nice script you can execute first for finding which process is consuming most of the watches. Then you can shut it down to focus on testing vscode.

Ok, so it seems like you did see the same issue before you increased the watcher limit, which is good to know.

Well, but only with a VSCode workspace which has thousands of files.

Yeah, can you locally clone https://github.com/paulmillr/chokidar and run it to watch a simple small folder and see if you get the same folder? Instructions are at https://github.com/paulmillr/chokidar#api

I believe I’m seeing the same thing on Fedora 29. To add some details, I have a folder containing 255 files, excluding node_modules. This is what I’m seeing for inotify consumption for Code:

   INOTIFY
   WATCHER
    COUNT     PID     CMD

    4270     6257  /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTy
    1617     6244  /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProje

This seems awfully high for just 255 files.

@bpasero it’s single folder I guess. I opened folder using Code.