I received this error message after a recent compile of a sketch on an Ubuntu
Linux computer:
"Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)
Sketch info:
Sketch uses 35279 bytes (72%) of program storage space. Maximum is 48640 bytes.
Global variables use 975 bytes (15%) of dynamic memory, leaving 5169 bytes for local variables. Maximum is 6144 bytes.
Is there any action necessary at this point? The link provided these suggestions:
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 .venv, are added to the files.watcherExclude setting (more details below). The current limit can be viewed by running:
cat /proc/sys/fs/inotify/max_user_watches
The limit can be increased to its maximum by editing /etc/sysctl.conf (except on Arch Linux, read below) and adding this line to the end of the file:
fs.inotify.max_user_watches=524288
The new value can then be loaded in by running sudo sysctl -p.
While 524,288 is the maximum number of files that can be watched, if you're in an environment that is particularly memory constrained, you may want to lower the number. 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.
Arch-based distros (including Manjaro) require you to change a different file; follow these steps instead.
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
}
The current limit can be viewed by running:
cat /proc/sys/fs/inotify/max_user_watches
ed@ed-G41MT-S2PT:~$ cat /proc/sys/fs/inotify/max_user_watches
65536
ed@ed-G41MT-S2PT:~$
Hi @edthewino. In some cases this warning can appear spuriously. This is tracked by the developers here:
It can also appear in cases where your sketch is in an exceptionally large folder.
The watching it is referring to is the feature where the Arduino IDE editor will reflect any changes you make to the sketch files externally (e.g., if you opened a file in an external text editor and made some changes to it there). Since Arduino IDE 2.x has a quite capable editor and even sketch file management capability (e.g., adding, renaming, deleting "tabs" from the sketch) already, I think that the average user doesn't ever rely on that file watching capability, so wouldn't notice even if it wasn't working on some occasions.
I agree that the message is confusing, and that link it provides doesn't help much either. I actually haven't seen this variant that mentions "Visual Studio Code" before. The ones I have seen look like this:
Note that the message you encountered mentions "Visual Studio Code", not "Visual Studio". Despite the similar names, these are two very different applications (the former of which is much more wonderful than the latter). The free open source Eclipse Theia IDE framework upon which Arduino IDE 2.x is built is partly based on VS Code and does leverage some of the open source code from VS Code, so this is likely where the mention of "VS Code" slipped into the warning.
Both products are produced by Microsoft so there is no problem with trademark infringement.
Since it seem you are not already familiar with it, I highly recommend you check out Visual Studio Code (more commonly known as "VS Code"). It is a very different product compared to Visual Studio so don't let any impressions you might have about Visual Studio dissuade you.
VS Code has been rated as the world's most popular programming editor/IDE for the last 6 years, consistently winning by a landslide:
As I mentioned above, there is a shared genealogy between Arduino IDE 2.x and VS Code. This means that those experienced with the Arduino IDE 2.x user interface will find the VS Code UI to be somewhat familiar from the start, and vice versa.