Unable to watch for file changes in this large workspace folder
Visual Studio Code User and Workspace Settings
Running Visual Studio Code on Linux ⇒ “Visual Studio Code is unable …
问题描述
Unable to watch for file changes in this large workspace folder. Please follow the instructions link to resolve this issue.
原因分析
- 或,工作目录的文件过多,导致 VS Code File Watcher 的句柄用完,而无法检测全部文件的变更。
- 或,其他程序占用过多 file handle 而导致 VS Code 无法正常运行。
解决方案
或,配置 fs.inotify.max_user_watches=524288 参数,来增加允许文件句柄数。根据文档:
… 524,288 is the maximum number of files that can be watched … Each file watch takes up 1080 bytes, so assuming that all 524,288 watches are consumed, that results in an upper bound of around 540 MiB …
或,忽略不必要的文件:
# .vscode/settings.json
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**": false
}
}