facebook / watchman

Watches files and records, or triggers actions, when they change.
https://facebook.github.io/watchman/
MIT License
12.57k stars 987 forks source link

EMFILE: too many open files, watch #923

Open deepakverma4 opened 3 years ago

deepakverma4 commented 3 years ago

i'm facing below issue while generating archive in xcode

node:events:371
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:204:21)
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.checkedEmitError (/Users/igesia/work/mobile/igesia_mobile/node_modules/sane/src/node_watcher.js:143:12)
    at FSWatcher.emit (node:events:394:28)
    at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  filename: null
}

i'm on 2021.06.07.00 version of watchman

any idea how to fix this?

sanirasheed commented 3 months ago

3. cd ios && rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install --repo-update

This worked for me!

gerhardsletten commented 1 month ago

I was able to solve this issue on a new M1 Macbook Air by just installing watchman directly with ARM version of brew (the one at /opt/homebrew/bin/brew) and tweaking the file descriptor sizes.

brew install watchman
sudo launchctl limit maxfiles 16384 16384 && ulimit -n 16384

I didn't have to change anything else.

Tweaking the file descriptor sizes did work for me in react-native@0.74.5 on a Mac with Apple M2.

from comment above

frg100 commented 4 weeks ago

i had the same problem with my M1 and a React Native project i tried to build/archive in Xcode. i first had to xcode-select --install but it gave me an estimate of 120 hours so i downloaded it manually from apple. Afterwards i could finally do brew install watchman, still had the error while i was trying to build/archive in xcode. After some debugging i found out that Xcode still didnt recognize watchman because it wasnt in its path. (For debugging measures i went to Target -> Build Phases -> Bundle React Native code and images and added a line watchman --version to check if watchman was recognized) After finding out it didnt, i added to the first line the path to my homebrew. export PATH=/opt/homebrew/bin:$PATH Then it finally worked :)

This finally worked for me too after so much struggling! You can set it in .xcode.env.local if you don't want to edit your build files

export NODE_BINARY=... # useful to pin your node version too
export PATH=/opt/homebrew/bin:$PATH
Magnifier030 commented 3 weeks ago

我的 M1 和我嘗試在 Xcode 中建置/存檔的 React Native 專案也遇到了同樣的問題。 我首先不得不這樣做,xcode-select --install但它給了我估計 120 小時,所以我從蘋果手動下載了它。後來我終於可以做到了brew install watchman,當我嘗試在 xcode 中建置/存檔時仍然遇到錯誤。經過一番調試後,我發現 Xcode 仍然無法識別 watchman,因為它不在其路徑中。 (為了調試措施,我Target -> Build Phases -> Bundle React Native code and images添加了一行來watchman --version檢查看守人是否被識別) 在發現它沒有被識別後,我在第一行添加了我的自製程序的路徑。export PATH=/opt/homebrew/bin:$PATH 然後終於成功了:)

this method worked for me !!!! thanks a lotttttt

dakshin-k commented 2 weeks ago

For future readers: If you ran brew install watchman after seeing this error, you also need to rm -rf node_modules && npm install before it will take effect.

angeloricardoweb commented 1 week ago

Works fine with me.

HuZinnia commented 6 days ago

MacOS: 3.0.1. xCode: 14.1 react-native: 0.62.3 node: 14.19.0 watchman: 2022.12.19.00 Yesterday everything worked. Today it's impossible to create release build due to exact this issue. Nothing from this thread helped (even stupid things a-la "recreate project in another directory")

Did you try this? -- rm -rf node_modules && npm install

This works, thanks!