Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC) #29

Open
lucbf opened this issue Apr 10, 2018 · 41 comments

Comments

@lucbf
Copy link

lucbf commented Apr 10, 2018

Apparently it needs this line fs.inotify.max_user_watches=524288 added to /etc/sysctl.conf

@AdrianKoshka
Copy link

vs-code-file-warning
Here's the warning

@biobii
Copy link

biobii commented Jul 13, 2018

I got the solution by following this instruction: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

Hope this help.

@apsrcreatix
Copy link

For Ubuntu users :
Run this in terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and clode the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
Thanks!

@lucbf
Copy link
Author

lucbf commented Apr 17, 2019

The problem is that as VS code is being sandboxed this wasn't working. May someone confirm if this isn't the case anymore?

@Joevonlong
Copy link

I follow the vs code instruction,
add line " fs.inotify.max_user_watches=524288 "
in last of /etc/sysctl.conf,
then run sudo sysctl -p,
but check cat /proc/sys/fs/inotify/max_user_watches
still not changed , still 8192

@h4ckfu
Copy link

h4ckfu commented Jun 17, 2019

I can confirm that this is still the case.

I'm pretty good at following instructions and I couldn't resolve it with the "Please follow the instructions link to resolve this issue."

@m1m6
Copy link

m1m6 commented Jun 25, 2019

Here tooo

@rajath002
Copy link

rajath002 commented Jun 29, 2019

I have updated sysctl.conf file with
fs.inotify.max_user_watches=524200
which as present in /etc location

after that executed sudo sysctl -p command.

after doing this step also when I execute
cat /proc/sys/fs/inotify/max_user_watches command then it will output
8192.

I'm totally clueless!!! whats going on here:(

@Crusiris
Copy link

Crusiris commented Jul 9, 2019

Hola Chicos, al parecer en linux funciona un poco diferente entonces en lugar de todo lo demás expuesto pueden probar con escribir en su terminal el comando:

echo fs.inotify.max_user_watches = 524288 | sudo tee -a /etc/sysctl.conf

y luego el comando:

sudo sysctl -p

luego para verificar escribir el comando:

cat/proc/sys/fs/inotify/max_user_watches

Espero que les sirva.

Para mas informacion https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

@cjbland
Copy link

cjbland commented Aug 13, 2019

@rajatkd I had to execute the following command on a RHEL 7.5 box:

sudo sysctl -p --system

@trotro
Copy link

trotro commented Oct 4, 2019

For Ubuntu users :
Run this in terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and clode the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
Thanks!

You have to relaunch the app to have the new fs.inotify.max_user_watches value taken by vscode sandboxed.

@tony-garcia
Copy link

I have never seen this before I just recently upgraded my linux box to Mint 19.2 and installed VSCode. Reading the instructions here, I see that typing this should give me that max number of files that can be watched:

cat /proc/sys/fs/inotify/max_user_watches

The answer I get is 8192. But the number of files in my workspace is 4! So why am I getting this message? I don't understand why I'd have to increase the file limit to 524288 in order to get rid of this notification.

@ludvikbrodl
Copy link

I have never seen this before I just recently upgraded my linux box to Mint 19.2 and installed VSCode. Reading the instructions here, I see that typing this should give me that max number of files that can be watched:

cat /proc/sys/fs/inotify/max_user_watches

The answer I get is 8192. But the number of files in my workspace is 4! So why am I getting this message? I don't understand why I'd have to increase the file limit to 524288 in order to get rid of this notification.

I have the exact same behaviour. I do not have sudo rights on my machine, and I don't think it should be needed to enable file change monitoring of small workspaces.

@actionanand
Copy link

Please execute this command echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

It'll solve your issue

@actionanand
Copy link

I follow the vs code instruction,
add line " fs.inotify.max_user_watches=524288 "
in last of /etc/sysctl.conf,
then run sudo sysctl -p,
but check cat /proc/sys/fs/inotify/max_user_watches
still not changed , still 8192

Please use this, it'll solve

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

@ghost
Copy link

ghost commented Nov 12, 2019

1.if you are working on angular project, go into the webapp from where you run project.
2.be super user
3.paste sysctl fs.inotify.max_user_watches=524288.
4.not exit form super user.
5.now run npm start in same path.
6.valid for centos and ubuntu user only.
Webp net-resizeimage (1)

@agaeb
Copy link

agaeb commented Dec 8, 2019

I ran into this issue because I had a Python venv with Jupyter and Matplotlib, which already gives 10k+ files in the .venv folder, exceeding the default maximum of 8192 watches. So I added
"**/.venv/**": true,
to files.watcherExclude in the settings to un-watch this folder. The files in it should change only when running pip commands to install/update packages anyway. The notification is now gone.

@ludvikbrodl
Copy link

I ran into this issue because I had a Python venv with Jupyter and Matplotlib, which already gives 10k+ files in the .venv folder, exceeding the default maximum of 8192 watches. So I added
"**/.venv/**": true,
to files.watcherExclude in the settings to un-watch this folder. The files in it should change only when running pip commands to install/update packages anyway. The notification is now gone.

Genious, thank you! I did not think about vscode also having file watchers on the venv. Perhaps if there was some way to see a list of the files being watched, not just the total number of files, one could more easily make decisions of what to put in files.watcherExclude.

@osman2491
Copy link

For Ubuntu users :
Run this in terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and close the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
Thanks!

@osman2491
Copy link

u wrote clode .....and it should be close

@tommysanterre
Copy link

Is there a way to list all the files being watched so we can tweak our "files.watcherExclude" config?

@asadlive84
Copy link

For Ubuntu or Linux Mint please open your terminal and put this command

sudo /bin/su -c "echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf"
sudo sysctl -p

@ArktosUro
Copy link

For Ubuntu users :
Run this in terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and clode the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
Thanks!

Really Works

@FilipeNMarques
Copy link

For Ubuntu users :
Run this in terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and clode the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
Thanks!

Thank you!!

@RISHABHAGRAWALZRA
Copy link

RISHABHAGRAWALZRA commented Jun 1, 2020

I have updated sysctl.conf file with
fs.inotify.max_user_watches=524200
which as present in /etc location

after that executed sudo sysctl -p command.

after doing this step also when I execute
cat /proc/sys/fs/inotify/max_user_watches command then it will output
8192.

I'm totally clueless!!! whats going on here:(

Yes I face the same problem but finally it worked
I added #fs.inotify.max_user_watches=524288 this in the file but we have to add this without hash symbol and then save it and try cat /proc/sys/fs/inotify/max_user_watches one more time it should work(it will show 524288)

@ArshiaSaleem
Copy link

Well, we are not allowed to edit systcl.conf file neither to change its permissions. Any clue?

@ArshiaSaleem
Copy link

Solved the issue by running with sudo but still its 8192

@ArshiaSaleem
Copy link

I was doing a silly mistake it worked thanks

@julmedvedeva
Copy link

hey! it's solves the problem just for Ubuntu. what can do Mac-users?

@gerrgg
Copy link

gerrgg commented Aug 7, 2020

Try this - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

https://stackoverflow.com/questions/53930305/nodemon-error-system-limit-for-number-of-file-watchers-reached

@julmedvedeva
Copy link

@gerrgg, Thanks!

@crojasd00
Copy link

I'd be good to have venv/ added as default to unwatch, I don't see why not seeing node_modules is already included by default.

@nightduck
Copy link

I can confirm @apsrcreatix 's fix works, but ever since I increased the file watch limit, both Chromium and VSCode (and spotify) will periodically freeze. (Usually for 10-15 seconds every few minutes or so). It's made my system completely unusable.

@CommandoSK
Copy link

@nightduck as it was mentioned before by @agaeb it is better to focus on resolving root cause rather than consequences. The reason is that virtual environment includes all the libraries that you need in virtual environment folder (5000+ files under /bin/lib based on number and size of modules that were installed). VSCode then tries to track changes in all of them as a result. Under normal circumstances you couldn't care less about those changes.

Fix does not require changing system settings, as most of the time your projects do not have thousands of files. In my case I needed to tryout Django, 200 files max, rest of those ~5700 were in venv folder (other ~2300 were watched by Baloo File Indexing). So I just excluded venv folder as described here (the "Another option is" paragraph).

After excluding entire virtual environment folder and running this neat script, I can easily see that VSCode watches only few files I am interested in. Hope this helps.

@Chimsy
Copy link

Chimsy commented Mar 28, 2021

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

@gerrgg Thank You Very Much

@Qodestackr
Copy link

Please execute this command echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

It'll solve your issue

sysctl: cannot stat /proc/sys/fs/notify/max_user_watches: No such file or directory

This is what I get

@ccaneke
Copy link

ccaneke commented May 18, 2021

The instructions here didn't directly fix this error for me when I had three projects opened in three visual studio code windows, I also had to close one visual studio code window together with the project that was opened in it.

So this error only disappeared after following the instructions here and closing one VS Code window so that I only had two projects opened in three windows instead of three projects opened in three windows.

@lucab
Copy link

lucab commented May 19, 2021

Starting from version 5.11, Linux kernel logic got updated to compute a dynamic default value for fs.inotify.max_user_watches based on the total amount of memory on the system.

As a datapoint, on a workstation with 8GiB of RAM this now gives ~60k max user-watches.
This could hopefully alleviate the issue for most users and workspaces. Very large ones could still hit the higher watches limit, in which case the sysctl can still be manually changed as shown in the docs.

@HL2222
Copy link

HL2222 commented Jul 28, 2022

what can do Mac-users?
what can do Mac-users?
what can do Mac-users?

@CommandoSK
Copy link

@HL2222 just check solution I provided on 7th December 2020. Don't focus on alternating OS rather focus on letting VSCode know that it does not have to watch all the files in your workspace. It's rarely the case that you need all of them watched.

@alanwilter
Copy link

I really wish I could understand how this work, because it's not working for me.

At first I had like 13K files in workspace. My .mypy_cache alone had 5K. My limit is 8192. I'm on a RH 7.5 (old, I know).

No matter what I do, nothing works. I did:

  "files.watcherExclude": {
    "**/.env/**": true,
    "**/.venv/**": true,
    "**/env/**": true,
    "**/venv/**": true,
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/samples/**": true,
    "**/_temp/**": true,
    "**/.mypy_cache/**": true,  # trying to exclude it
    "**/.mypy_cache/*/**": true # I frankly don't know the diff
  },

Then I even deleted the .mypy_cache folders occurrence. I restarted vscode and the message is always there. I do find . -type f | wc -l and I have less than 8K files.

Some details.

  • I'm using vscode-remote (code --remote ssh-remote+server /path/to/workspace/)
  • I have 3 symlinks to files, not folders, in my workspace.

Just wondering if symlinks may play a role here.

This ticket issue was opened 5 years ago!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests