2
  • VSCode Version: 1.47.1
  • Local OS Version: Windows 10.0.19041 N/A Build 19041
  • Remote OS Version: NAME="Ubuntu" / VERSION="14.04.5 LTS, Trusty Tahr"
  • Remote Extension/Connection Type: SSH

Upon connection, VSCode says

"Unable to watch for file changes in this large workspace. Please follow the instructions link to resolve this issue."

which is explained in detail at: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

I'd like to try limiting the file watcher's scope. I think it is currently trying to watch ALL the files in the server, not just my files in a small directory.

Official documentatoin says:

Another option is to exclude specific workspace directories from the VS Code file watcher with the files.watcherExclude setting. The default for files.watcherExclude excludes node_modules and some folders under .git, but you can add other directories that you don't want VS Code to track.

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true   }

But my question is:

Where does file watcher "watch"? In what scope? Does it attempt to watch ALL the files in the server? When I added these settings (actually, only below 2 lines) to .vscode/settings.json, file watcher warning STOPPED popping out.

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/.hg/store/**": true,

    "/**": true,
    "/home/my-user-name-john-doe/**": false
  }

I was trying to say: "Hey VSCode, stop watching all the file changes in the / root directories and only focus on MY directory."

Did I make myself clear here? Is the above settings does exactly what I was trying to say?


I'm getting an error that says:

Is it provoked by the changes in the settings.json?

enter image description here

user8491363
  • 143
  • 1
  • 9
  • Hello. In order to point you in the right direction, we need to know which operating system you are running. – iskyfire Jul 16 '20 at 04:38
  • @iskyfire Right, I added os info at the top. – user8491363 Jul 16 '20 at 04:48
  • I believe the error is originating from the `"/**"`. I do not believe you can place an exclusion starting from the root directory as it would prevent any files from being loaded. The `"files.watcherExclude":` is mainly used if your code base is using a large amount of data files in a sub-directory, or if you have a sub-directory that contains another `node_modules` folder. I would check to see if you have any other `node_modules` folders, and if you do, exclude its parent folder. If that doesn't work, then we can instead look at the output of `cat /proc/sys/fs/inotify/max_user_watches` – iskyfire Jul 16 '20 at 04:58
  • Then, you can compare the output of `max_user_watches` to how many files are in your current project using `find . -type f | wc -l` on the remote server in the workspace directory. You can even remove folders from that search with `find . -type f -not -path '**/node_modules/**' | wc -l` to help you narrow down where the large amount of files may be coming from. – iskyfire Jul 16 '20 at 05:15
  • @iskyfire Maybe that was one of the issues but regardless of commenting out "/**": true, "/home/my-user-name-john-doe/**": false that I added, the problem persisted. However, disabling all extensions and enabling bare minimum solved the problem for now. Because of random nature of this error, I can't tell if the problem is "really" solved but up to now, the problem is gone! – user8491363 Jul 16 '20 at 10:14

1 Answers1

0

I found that this problem is due to the directory level on which you open your file explorer. That is, when you open the file explorer, VS code auto-fills the directory to open with /home/yourUsername. If you accept this, then it only watches files in your home directory. However, if you change this to the root ( / ), then it will create file watches for everything in the entire OS, and devour your system resources.

Since you're not connecting remotely as root (right?), you can't access root-level directories through the file explorer anyway.

Adam Winter
  • 101
  • 1