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

Error when archiving in XCode: EMFILE #29915

Closed
TheRealNate opened this issue Sep 9, 2020 · 21 comments
Closed

Error when archiving in XCode: EMFILE #29915

TheRealNate opened this issue Sep 9, 2020 · 21 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@TheRealNate
Copy link

TheRealNate commented Sep 9, 2020

This error has been reported before, but the solution did not help me.

Description

I am seeing this error when archiving from XCode. I have not encountered this issue before and have tried reverting my code:

node /.../node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output ... --assets-dest ...

warning: the transform cache was reset.
                 Welcome to React Native!
                Learn once, write anywhere


events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:127:28)
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.checkedEmitError (/Users/.../node_modules/sane/src/node_watcher.js:143:12)
    at FSWatcher.emit (events.js:311:20)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:133:12) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  filename: null
}

I have tried the following steps to fix:

  • Reinstall Watchman (sudo port uninstall watchman, sudo port install watchman, reboot) (this has been the solution on similar issues but has not helped me)
  • Reset Cocoapods (Deintegrate, rm Pods/, reinstall etc)
  • Reset Watchman Cache (watchman watch-del-all)
  • Clean Build Folder in XCode

If I run the bundle command manually from terminal it succeeds, it only seems to have a problem when archiving from XCode.

I also run npx react-native doctor and there is a ✅ next to Watchman

Versions:

Environment: macOS Catalina
React Native CLI Version: 4.10.1
Node Version 12.16.1
React Native Version: 0.63.2
Watchman Version: 4.9.0

@TheRealNate
Copy link
Author

TheRealNate commented Sep 14, 2020

Interesting development. If I manually run the xcodebuild command the archive succeeds:

xcodebuild -workspace ... -scheme ... archive

Isn't this basically identical to Product > Archive in XCode? Are there any explanations for this?

Another note: Another much smaller RN app archives successfully in XCode on my machine.

@stale
Copy link

stale bot commented Dec 25, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 25, 2020
@watanabeyu
Copy link
Contributor

same issue ...

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 7, 2021
@jdbarrera
Copy link

I am getting the same error. The program builds fine in the command line but has this error when built in xCode.

@alexyangjie
Copy link

Same issue here.

@alexfoxy
Copy link

alexfoxy commented May 7, 2021

I am also experiencing this issue. It occurs at the Bundle React Native code and images build phase. React Native: 0.63.4.

@Natteke
Copy link

Natteke commented Jun 8, 2021

still exist RN 0.64. tried nodejs 14 / 16. Watchman installed. OS BigSur. chip M1

ulimit -a:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 524288
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8176
cpu time (seconds, -t) unlimited
max user processes (-u) 2000
virtual memory (kbytes, -v) unlimited

Reinstalling watchman and changing kern.maxfilesperproc / kern.maxfiles not helps.
Changing node version also pointless.

@ekram21
Copy link

ekram21 commented Jun 22, 2021

Same issue on Macbook M1. The issue in my opinion is that the metro bundler does not start up inside a separate new terminal like it does when I am archiving in my intel macbook. The metro bundler attempts to start inside the xcode where it does not let watchman work properly so this error gets thrown.

@ekram21
Copy link

ekram21 commented Jun 23, 2021

This got fixed recently in newest version of watchman. The problem was with bug in fsevents library for mac m1 which got fixed in latest release. Update your watchman, reinstall your project, pods everything and things should work

@jdbarrera
Copy link

@ekram21 I upgraded watchman, yarn install, and npx pod-install and I am still getting the same error. Am I missing something?

@ekram21
Copy link

ekram21 commented Jun 25, 2021

@ekram21 I upgraded watchman, yarn install, and npx pod-install and I am still getting the same error. Am I missing something?

I don't know your environment and what device you are using but I will list the things to keep in mind:

  • This is for MAC M1 Silicon
  • Latest Versions of Node, React Native being used
  • Latest Versions of Watchman and Brew being used
  • I did not use Yarn. NPM install used to install all node modules and navigated to iOS folder and just used pod install - consult these thread if pod install doesn't work: React Native project pod install error with M1 MacBook Pro , how to resolve this issue? CocoaPods/CocoaPods#10349
  • Make duplicate terminals with one running on Rosetta and the other native.
  • Brew should be installed with native terminal, and then watchman after
  • After this you need open Settings - Security Preference and give complete disk access to xcode, watchman, terminal and any other tools being used in your environment.
  • Your project cannot be under desktop or downloads. Make sure it is under /Users/myname/

Also look at this thread: facebook/metro#668

These are the steps I followed to make the project archive in xcode. Note that the project would compile fine in simulator outside of xcode before but the above steps finally got it to archive in xcode where it was failing

EDIT: Also if everything fails then please reset your device, install all latest versions of software needed, follow above steps and then create a clean react-native project using latest watchman and all tools and see if it archives properly. Some people I know have reported success in this method compared to working with existing projects. If this works you can then slowly start figuring out which module is causing problem in existing project.

@deepakverma4
Copy link

@ekram21 which watchman version are you using?

@chaohuichen
Copy link

any updates on this issue?

I am getting the same issues

`events.js:377
throw er; // Unhandled 'error' event
^

Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:178:28)
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.checkedEmitError (/Users/chaohuichen/Desktop/PCC/fillup/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (events.js:400:28)
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:184:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
`

@eshunnar
Copy link

eshunnar commented Dec 7, 2021

Interesting development. If I manually run the xcodebuild command the archive succeeds:

xcodebuild -workspace ... -scheme ... archive

Isn't this basically identical to Product > Archive in XCode? Are there any explanations for this?

Another note: Another much smaller RN app archives successfully in XCode on my machine.

Works for me with same error on latest version of watchman error.

@sachin-blinkdigital
Copy link

Still Same issue on MacBook M1

@majirosstefan
Copy link

majirosstefan commented Apr 26, 2022

still present

EDIT:
I am using this script under "Bundle React Native code and images" and it seems to be working for me when using nvm:

export SENTRY_LOG_LEVEL=debug
export SENTRY_PROPERTIES=sentry.properties
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export NODE_BINARY=$(which node)
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh --force-foreground
../node_modules/expo-updates/scripts/create-manifest-ios.sh

@JulianKingman
Copy link

I started having this issue after upgrading to yarn 2

@hernancasillas
Copy link

Still

@acamara2016
Copy link

same here, currently on Venture 13.1 trying to run yarn test

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 13, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests