{"id":14309,"date":"2022-03-09T14:54:55","date_gmt":"2022-03-09T13:54:55","guid":{"rendered":"https:\/\/hesmid.nl\/test\/?p=14309"},"modified":"2022-03-11T10:53:52","modified_gmt":"2022-03-11T09:53:52","slug":"too-many-watched-files-vscodium-linux","status":"publish","type":"post","link":"https:\/\/hesmid.nl\/test\/too-many-watched-files-vscodium-linux\/","title":{"rendered":"Too many watched files (vscode, linux)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc\">&#8220;Visual Studio Code is unable to watch for file changes in this large workspace&#8221; (error ENOSPC)<a is=\"\" href=\"https:\/\/code.visualstudio.com\/docs\/setup\/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc\">#<\/a><\/h3>\n\n\n\n<p>When you see this notification, it indicates that the VS Code file watcher is running out of handles because the workspace is large and contains many files. Before adjusting platform limits, make sure that potentially large folders, such as Python&nbsp;<code>.venv<\/code>, are added to the&nbsp;<code>files.watcherExclude<\/code>&nbsp;setting (more details below). The current limit can be viewed by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/sys\/fs\/inotify\/max_user_watches<\/code><\/pre>\n\n\n\n<p>The limit can be increased to its maximum by editing&nbsp;<code>\/etc\/sysctl.conf<\/code>&nbsp;(except on Arch Linux, read below) and adding this line to the end of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fs.inotify.max_user_watches=524288<\/code><\/pre>\n\n\n\n<p>The new value can then be loaded in by running\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -p<\/code><\/pre>\n\n\n\n<!--more-->\n\n\n\n<p>While 524,288 is the maximum number of files that can be watched, if you&#8217;re in an environment that is particularly memory constrained, you may want to lower the number. Each file watch\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/stackoverflow.com\/a\/7091897\/1156119\" target=\"_blank\">takes up 1080 bytes<\/a>, so assuming that all 524,288 watches are consumed, that results in an upper bound of around 540 MiB.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.archlinux.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Arch<\/a>-based distros (including Manjaro) require you to change a different file; follow&nbsp;<a href=\"https:\/\/gist.github.com\/tbjgolden\/c53ca37f3bc2fab8c930183310918c8c\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a>&nbsp;instead.<\/p>\n\n\n\n<p>Another option is to exclude specific workspace directories from the VS Code file watcher with the&nbsp;<code>files.watcherExclude<\/code>&nbsp;<a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/settings\">setting<\/a>. The default for&nbsp;<code>files.watcherExclude<\/code>&nbsp;excludes&nbsp;<code>node_modules<\/code>&nbsp;and some folders under&nbsp;<code>.git<\/code>, but you can add other directories that you don&#8217;t want VS Code to track.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"files.watcherExclude\": {\n    \"**\/.git\/objects\/**\": true,\n    \"**\/.git\/subtree-cache\/**\": true,\n    \"**\/node_modules\/*\/**\": true\n  }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_creating-user-and-workspace-settings\">Creating User and Workspace Settings in VScode<\/h2>\n\n\n\n<p><a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/settings\">https:\/\/code.visualstudio.com\/docs\/getstarted\/settings<\/a><\/p>\n\n\n\n<p>To open your user and workspace settings, use the following VS Code menu command:<\/p>\n\n\n\n<ul><li>On Windows\/Linux &#8211;&nbsp;<strong>File<\/strong>&nbsp;&gt;&nbsp;<strong>Preferences<\/strong>&nbsp;&gt;&nbsp;<strong>Settings<\/strong><\/li><li>On macOS &#8211;&nbsp;<strong>Code<\/strong>&nbsp;&gt;&nbsp;<strong>Preferences<\/strong>&nbsp;&gt;&nbsp;<strong>Settings<\/strong><\/li><\/ul>\n\n\n\n<p>You can also open the Settings editor from the\u00a0<strong>Command Palette<\/strong>\u00a0(Ctrl+Shift+P) with\u00a0<strong>Preferences: Open Settings<\/strong>(json)\u00a0or use the keyboard shortcut (Ctrl+,).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"491\" src=\"https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/03\/image-1.png\" alt=\"\" class=\"wp-image-14310\" srcset=\"https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/03\/image-1.png 829w, https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/03\/image-1-300x178.png 300w, https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/03\/image-1-150x89.png 150w, https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/03\/image-1-768x455.png 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"VS Code Setting: files.watcherExclude\" width=\"648\" height=\"486\" src=\"https:\/\/www.youtube.com\/embed\/WMNua0ob6Aw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;Visual Studio Code is unable to watch for file changes in this large workspace&#8221; (error ENOSPC)# When you see this notification, it indicates that the VS Code file watcher is running out of handles because the workspace is large and contains many files. Before adjusting platform limits, make sure that potentially large folders, such as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[730,731],"acf":[],"_links":{"self":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14309"}],"collection":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/comments?post=14309"}],"version-history":[{"count":2,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14309\/revisions"}],"predecessor-version":[{"id":14319,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14309\/revisions\/14319"}],"wp:attachment":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/media?parent=14309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/categories?post=14309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/tags?post=14309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}