익명 17:31

Only include a single directory in VSCode file watcher

Only include a single directory in VSCode file watcher

  • 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



Top Answer/Comment:

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.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다