gatsbyjs/gatsby

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static'

omrllm opened this issue · 107 comments

Description

The web app compiles but when I reload the website, the compilation end with an error.

Steps to reproduce

Just type gatsby develop and if you click an article for example or you reload (ctrl + r) the website compilation will end.

Repo: There you go.

Expected result

gatsby develop should work.

Actual result

success open and validate gatsby-configs — 0.015 s
success load plugins — 0.382 s
success onPreInit — 0.606 s
success delete html and css files from previous builds — 0.133 s
success initialize cache — 0.013 s
success copy gatsby files — 0.052 s
success onPreBootstrap — 0.006 s
success source and transform nodes — 0.164 s
success building schema — 0.393 s
success createPages — 0.086 s
success createPagesStatefully — 0.072 s
success onPreExtractQueries — 0.006 s
success update schema — 0.224 s
success extract queries from components — 0.216 s
success run graphql queries — 0.164 s — 14/14 88.14 queries/second
success write out page data — 0.004 s
success write out redirect data — 0.001 s
⢀ onPostBootstrapdone generating icons for manifest
success onPostBootstrap — 0.274 s

info bootstrap finished - 4.655 s

 DONE  Compiled successfully in 1926ms                                                                                                               1:43:58 AM


You can now view abcrypto in the browser.

  http://localhost:8000/

View GraphiQL, an in-browser IDE, to explore your site's data and schema

  http://localhost:8000/___graphql

Note that the development build is not optimized.
To create a production build, use gatsby build

ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
error UNHANDLED EXCEPTION


  Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static'

  - watchers.js:165 FSWatcher.start
    internal/fs/watchers.js:165:26

  - nodefs-handler.js:37 createFsWatchInstance
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:37:15

  - nodefs-handler.js:80 setFsWatchListener
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:80:15

  - nodefs-handler.js:232 FSWatcher.NodeFsHandler._watchWithNodeFs
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:232:14

  - nodefs-handler.js:414 FSWatcher.NodeFsHandler._handleDir
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:414:19

  - nodefs-handler.js:462 FSWatcher.<anonymous>
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:462:19

  - nodefs-handler.js:467 FSWatcher.<anonymous>
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:467:16

Environment

System:
    OS: Linux 4.20 Fedora 29 (Workstation Edition) 29 (Workstation Edition)
    CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
    Shell: 4.4.23 - /bin/bash
  Binaries:
    Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node
    Yarn: 1.12.3 - /var/lib/snapd/snap/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.3.0/bin/npm
  Languages:
    Python: 2.7.15 - /usr/bin/python
  Browsers:
    Firefox: 64.0.2
  npmPackages:
    gatsby: ^2.0.104 => 2.0.104
    gatsby-cli: ^2.4.8 => 2.4.8
    gatsby-image: ^2.0.29 => 2.0.29
    gatsby-plugin-catch-links: ^2.0.9 => 2.0.9
    gatsby-plugin-feed: ^2.0.12 => 2.0.12
    gatsby-plugin-google-analytics: ^2.0.12 => 2.0.12
    gatsby-plugin-manifest: ^2.0.14 => 2.0.14
    gatsby-plugin-offline: ^2.0.22 => 2.0.22
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.5
    gatsby-plugin-sharp: ^2.0.18 => 2.0.18
    gatsby-plugin-typography: ^2.2.6 => 2.2.6
    gatsby-remark-copy-linked-files: ^2.0.5 => 2.0.8
    gatsby-remark-images: ^2.0.4 => 2.0.6
    gatsby-remark-prismjs: ^3.2.3 => 3.2.3
    gatsby-remark-responsive-iframe: ^2.0.5 => 2.0.8
    gatsby-remark-smartypants: ^2.0.5 => 2.0.7
    gatsby-source-filesystem: ^2.0.18 => 2.0.18
    gatsby-transformer-remark: ^2.2.2 => 2.2.2
    gatsby-transformer-sharp: ^2.1.12 => 2.1.12
  npmGlobalPackages:
    gatsby-cli: 2.4.8
    gatsby: 2.0.98

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Alright I restarted the computer, and now everything works fine again.

I solved this way
https://code.visualstudio.com/docs/setup/linux
"Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)#

cat /proc/sys/fs/inotify/max_user_watches

fs.inotify.max_user_watches=524288

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thank you very much!!!

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

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

it saved my day

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

I ran this line of code in a react-app and everything went back to normal again, thanks!!

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thanks. it's really helpfull

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

Thanks man , you are a hero

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

Give me the error:
sysctl: illegal option -- p

Using on MacOS

Serve your app as root.....It's work!

Serve your app as root.....It's work!

Could you explain ?

Run sudo npm run serve inside you app folder or run this commands as below:

  • su
  • enter your password
  • npm run serve

Noooooooo don't run your app as root! 💀 🚨 That can cause all kinds of security problems!

What if I deploy to netlify and encounter that error when netlify tries to build the app? On local it's fine

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

Yes It is working

i-bsd commented

I'm getting this error on Netlify.
Anyone know how to fix it?

I got it today too and did a "clear cache and redeploy" and it worked.

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

worked too. thanks

It’s hitting your system's file watchers limit

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

Reopening this since it looks the above is a popular answer and that this issue is prevalent enough to warrant better resources/warnings on

We should do two things for now:

  • Add the quoted answer in documentation
  • Investigate how to catch this in Gatsby and add a more helpful error that enables the user to resolve this themselves

@sidharthachatterjee where exactly do you see this quoted in the documentation, what page? 🤔

@sidharthachatterjee, is this taken ? If not, I can take it up, but definitely need your help. :D

@eduarmreyes That's a very good question! Perhaps a new page linked to in https://www.gatsbyjs.org/docs/debugging/

@KirankumarAmbati If @eduarmreyes is taking up the documentation you could try out the second point in the list! Happy to help 🙂

I'm currently working on this. @sidharthachatterjee I'm unable to assign or add labels. Thanks for your help!

I still get this occasionally on Netlify with gatsby build, even through my project is fairly small. It's difficult to debug, because it doesn't occur every time. Clearing the cache & redeploying will fix it, but also, just a normal re-deploy will often work.

There's no sudo access during netlify builds, so changing the system limit isn't an option. Also, manually re-deploying isn't a real "solution" - I have client websites that rebuild after CMS changes, and I don't want to be 'on call' to click the 'redeploy + clear cache' button whenever this happens.

Is there a way to see and/or limit what files are being watched? I don't know much about how Gatsby works under the hood, but, assuming that gatsby watches files in order to re-build while developing, does gatsby build really need to be watching anything in the first place?

It's work fine for me !
Thanks very much !

I still get this issue with Gatsby 2.13.73, and as @good-idea wrote, manually re-deploying is not a viable long term solution especially when making websites for clients with CMS.
Why do files even need to be "watched" when building for production?

8:10:54 AM: error watch /opt/build/repo/gatsby-config.js ENOSPC
8:10:54 AM: UNHANDLED EXCEPTION watch /opt/build/repo/gatsby-config.js ENOSPC
8:10:54 AM: See our docs page for more info on this error: https://gatsby.dev/issue-how-to
8:10:54 AM: 
8:10:54 AM:   Error: watch /opt/build/repo/gatsby-config.js ENOSPC
8:10:54 AM:   
8:10:54 AM:   - nodefs-handler.js:38 createFsWatchInstance
8:10:54 AM:     [repo]/[chokidar]/lib/nodefs-handler.js:38:15
8:10:54 AM:   
8:10:54 AM:   - nodefs-handler.js:81 setFsWatchListener
8:10:54 AM:     [repo]/[chokidar]/lib/nodefs-handler.js:81:15
8:10:54 AM:   
8:10:54 AM:   - nodefs-handler.js:233 FSWatcher.NodeFsHandler._watchWithNodeFs
8:10:54 AM:     [repo]/[chokidar]/lib/nodefs-handler.js:233:14
8:10:54 AM:   
8:10:54 AM:   - nodefs-handler.js:262 FSWatcher.NodeFsHandler._handleFile
8:10:54 AM:     [repo]/[chokidar]/lib/nodefs-handler.js:262:21
8:10:54 AM:   
8:10:54 AM:   - nodefs-handler.js:495 FSWatcher.<anonymous>
8:10:54 AM:     [repo]/[chokidar]/lib/nodefs-handler.js:495:21
8:10:54 AM:   

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thanks man! it saved my time 🙌

it still happens ... with the quick start guide 👀

image

Note that @pieh answered the question of "why do files need to be watched while building for production?" over in #15843:

Because used package for globbing + watching (chokidar) doesn't have way to disable watching. We were looking for alternatives, but there were none that actually allow to disable watching. We could use different packages for builds (so only globbing, without watching) and develop (globbing + watching) - but this introduce potential to cause differences between builds and develop

Looks like this issue should be taken up with chokidar first to add a watch option, then a followup issue created for Gatsby to implement the watch option.

thank you so much!! It worked for me :D

Also, chokidar isn't going to add an option to disable watching, since it's literally a file watcher. The only possible solution I can think of would be for Gatsby to switch to a different library for traversing directories that allows both watch and non-watch options.

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Dang Sid beat me to the punch i was ganna say this yea it has to do with (Im assuming your on linux) how linux has there default setup of file watchers its an easy fix just by running that command in terminal or you can go here https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc on VS Code website they have a whole section on it teaching you how to solve this issue

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

Hello! Any updates on this issue? I encounter this occasionally when building my gatsby site in Jenkins. I don't have permissions to the modify the inotify max_user_watches in my Jenkins build environment.

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@ethannkschneider I was running into this problem when building in a restrictive Jenkins environment as well. Using CHOKIDAR_USEPOLLING=1 avoids hitting the watched limit for me.

Following is the best solution.
Hit the command - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

delete react node_modules

rm -r node_modules

yarn or npm install

yarn start or npm start

if error occurs use this method again

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Tks!!!

@cedricdelpoux did you solve this error?

Give me the error:
sysctl: illegal option -- p

Using on MacOS

got the same issue:
solved with: increasing users.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

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

Is work!!

@irokhes sysctl -p is used to reload the changed config from /etc/sysctl.conf on Linux. You will have to find out how to change sysctl.conf (probably located somewhere else) on Mac. Then you can change the fs.inotify.max_user_watches-property (if it is called the same on Mac).

I just had to close Visual Studio Code and that solved the problem.

If you are not interested in the technical details and only want to get Listen to work:

If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:

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

If you are running ArchLinux, run the following command instead (see here for why):

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

Then paste it in your terminal and press on enter to run it.

More info: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

Alright I restarted the computer, and now everything works fine again.

Thanks! It the computer's way of saying "restart me"

This is happening here in Travis too, I think the crux of the issue is it's watching /static. Even if it has to run chokidar in build mode, if we could pass a watch ignore pattern, we could ignore folders like static. Unless doing so would prevent it from copying to build? 🤔 Using CHOKIDAR_USEPOLLING=1 seems to help.

I followed the 'fix' to set max watchers to 524288, rebooting, none of it fixed the issue. I'm sure it helped, but I was still experiencing this issue.

I added the environment variable using:

  • export CHOKIDAR_USEPOLLING=1

And that helped. I was able to run gatsby develop on my site.

That's what I meant in my last post. I tried that exact command and it did not work. I'm running Ubuntu 18.04. However, running that command, rebooting, then changing the CHOKIDAR_USEPOLLING environment variable worked.

Same for me.
Combination of fs.inotify.max_user_watches=524288 in /etc/sysctl.conf and command

CHOKIDAR_USEPOLLING=1 node --max_old_space_size=4096 ./node_modules/.bin/gatsby develop -S

works but not at all the time, sometimes computer restart is need.
So this issue has not been solved yet.

OS: macOS Catalina 10.15.4
CPU: Intel i7-4750HQ (8) @ 2.00GHz
Memory: 8192MiB

Gatsby CLI version: 2.11.5
Gatsby version: 2.20.12
Node: v13.12.0

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

save my day, thanks!!

instead of increase max_user_watches, webpack watcher should not watch 1 million file inside node_modules!

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thanks,

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

This worked for me

Está atingindo o limite de observadores de arquivos do seu sistema
Tentar echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Leia mais sobre o que está acontecendo em https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Muito obrigado!!!

Thanks, solved

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thanks 😄

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

Thanks this works on Ubuntu 18.04 LTS

nidri commented

export CHOKIDAR_USEPOLLING=1
worked.

Please just add a reaction to the solution that worked for you, rather than making a new comment that just says "worked for me".

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

Thank You so much!!!

If anyone was curious about the numbers and overhead, I ended up looking into it a bit rather than just copying what appears like random numbers online and hoping for the best :P

The 524288 mentioned here and some other places from the guard/listen wiki (seems to be original source?), is 2^19 (exponent, as in 2x2x2x2..19 times), where each watch(only when actually used) requires 1,080 bytes of memory, meaning you would use 540MiB of RAM if you managed to use all those, just for the file watchers.

There's also this handy script, which can tell you where all the watchers are allocated to presently. In my case I had been using a max_user_watches of 2^16 (65536) and two electron processes(VS Code) had 24-28k watches each active, a few others had a few thousand each, and minor watches for everything else.


@x0xl0ma in future just add a 👍 to the comment that helped you, if your comment doesn't provide any value for others due to being a thankyou (🎉) or repeating confirmation, it just adds noise that others have to wade through (notice that Github hides 30+ comments on this thread as an optimization, that can hide good/useful information that might be missed in a sea of "thanks" and "works".

@omrllm

Alright I restarted the computer, and now everything works fine again.

in reality when you

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

you didn't had to restart your computer since sudo sysctl -p reload and apply system parameters to the current system

Error: ENOSPC: System limit for number of file watchers reached,

I am having this issue

Tried
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
but didn't work for me.

Error: ENOSPC: System limit for number of file watchers reached

I am facing this issue when i started my React app for next time

Please try with this below code:- (in your terminal)

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

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

thank you sir, it worked. So precise.

Alternative solution for vscode:

Instead of increasing limits you could also add public and .cache folders to files.watcherExclude

"files.watcherExclude": {
    "**/public/**": true,
    "**/.cache/**": true
}

or

image

via https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

It’s hitting your system's file watchers limit
Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thank you very much!!!

Thank you for providing the right issue where we should looked for in!!!

ENOSPC = Erro NO Seu PC
@Victorcorcos

Instead of allowing Webpack to watch half a million files in node_modules (which you are never going to change), you can tell it ignore certain directories, like node_modules: https://webpack.js.org/configuration/watch/#watchoptionsignored

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

Works for me! Thankss! :D

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

tanks!!!

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thank you very match :), why does this setting have that low number of file watchers by default? mmm

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thankss!!

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Work fiine, thank's !!!

yes something to do with atom also.. when atom open in my gatsby directory.. hangs onto the file
close atom.. all coolio

Está atingindo o limite de observadores de arquivos do seu sistema

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

Leia mais sobre o que está acontecendo em https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Resolveu muito mais do que esperava!

In ubuntu you can do the following steps
###sudo vim /etc/sysctl.conf
add the line
###fs.inotify.max_user_watches=524288
save the file .
###npm start

this should work
Thanks

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Gracias crack, leyenda, titán!

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Works for me. Thank you :D

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thanks mate, it saved my day!

It’s hitting your system's file watchers limit
Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thank you very much!!!

There is a shortcut to setting this parameter. This accomplishes the same thing as the top voted answer:

sudo sysctl fs.inotify.max_user_watches=524288

Thanks smac.. u guys rock

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Worked for me, thank so much!

Error: ENOSPC: System limit for number of file watchers reached,

I am having this issue

Tried echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p but didn't work for me.

Using the sysctl -p approach after setting fs.inotify.max_user_watches did not work for me , either. (by the way this setting was already set to a high value, likely from me trying to fix this issue a while back ago).

The best solution to the problem I found here:

  1. Use this script to identify which processes are requiring the most file watchers in your session.
  2. You can then query the current max_user_watches value with sysctl fs.inotify.{max_queued_events,max_user_instances,max_user_watches} and then set it to a different value (a lower value may do it)
    sudo sysctl -w fs.inotify.max_user_watches=16384
  3. Or you can simply kill the process you found in (1) that consumes the most file watchers (in my case, baloo_file)
  4. The above, however, will likely need to be done again when restarting the system - the process we identified as responsible for taking much of the file watchers will (in my case - baloo_file) - will again so the same in the next boot. So to permanently fix the issue - either disable or remove this service/package. I disabled it: balooctl disable.

Now run sudo code --user-data-dir and it should open vscode with admin privileges this time. (by the way when it does not run sudo code --user-data-dir --verbose to see what the problem is - that's how I figured out it had to do with file watchers limit).

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Its working

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Worked for me, Linux OS

Alternative solution for vscode:

Instead of increasing limits you could also add public and .cache folders to files.watcherExclude

"files.watcherExclude": {
    "**/public/**": true,
    "**/.cache/**": true
}

or

image

via https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

This is the actual solution in my case. It turned out that my watcher exclude pattern had an error. It excluded **/node_modules/*/** instead of **/node_modules/**.

Increasing the system's fs.inotify.max_user_watches only helped counter the symptoms of this error, and didn't help any more when even more folders were added to node_modules.

via https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
Link does not look right.

I just quote-replied and referenced an answer higher up in the conversation.

I'm running into this issue on Google Kubernetes Engine (GKE) because you don't appear to have the ability to increase the default fs.inotify.max_user_watches.

Please stop telling people to increase the user watches to such a ridiculously high number. The default value is 8192 for a reason. Each watch consumes 1080 bytes of kernel memory on a 64-bit system. Setting the limit to such a high number would allow EACH USER on the system to potentially allocate number of watches * 1080 bytes of memory.

Tell them to increase the value in small steps until things start to work.

It’s hitting your system's file watchers limit

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

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thanks mate, you are a hero

If you are getting this error because you are working on a REACT/STRAPI or NODE or something related to javascript and react vis Ubuntu then below will help you.

run this on your terminal

sudo gedit /etc/sysctl.conf

Add a line at the bottom

fs.inotify.max_user_watches=524288

Then save and exit!

sudo sysctl -p

to check it

Then it is solved!

go back to your VS-CODE or any IDE you are using and run your code again