Open deepakverma4 opened 3 years ago
Same problem here with the same version 2021.06.07.00
on an Apple Silicon Macbook (m1).
But in my case, there is a slight nuance (I don't know if it's your case too @deepakverma4):
/usr/local/Homebrew
), no problem to bundle my javascript files./opt/homebrew
), I get the EMFILE: too many open files
errorKnowing that I tried a lot of random things like increasing a lot the ulimit in:
Start Packager
XCode scriptBundle React Native code
XCode scriptsudo launchctl limit maxfiles 65536 unlimited
But nothing worked. :/
For me,
I UNCHECKED "Open using Rosetta" for Xcode,
and added arm64 in Excluded Architecture in:
[TARGET]/Build Settings Architectures/Excluded Architectures
Getting the same error: The project has been working fine until now.
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/myusername/code/Uyaphi/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 } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
i solved this error by following below steps
1) clone your repo into some separate location
2) run npm i
3) reset all caches by running this command
cd ios && rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/\*; pod deintegrate; pod setup; pod install --repo-update
i solved this error by following below steps
- clone your repo into some separate location
- run
npm i
- reset all caches by running this command
cd ios && rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/\*; pod deintegrate; pod setup; pod install --repo-update
This work perfectly so I am assuming it was caching, Thank you! @deepakverma4
The above steps to clear cache didn't work for me.
- If I run metro from a terminal running in Rosetta mode, with watchman installed using x86_64 brew (
/usr/local/Homebrew
), no problem to bundle my javascript files.- If I run metro from a regular terminal (without Rosetta mode), with watchman installed using arm64 brew (
/opt/homebrew
), I get theEMFILE: too many open files
error
Thanks so much for this, installing watchman using x86_64 brew and adding it to my PATH
let me build the app. Additionally, I had to follow this to get watchman working: https://github.com/facebook/watchman/issues/640#issuecomment-416983649
I am facing the same issue and I want to investigate more and work on this issue, can you please assign it to me.
I have the same issue with the recent archive on my M1 MacBook air with Xcode 13.0 version.
`warning: the transform cache was reset. Welcome to React Native! Learn once, write anywhere
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)`
Can someone please help me how to resolve it thanks
I was also facing this issue while building archive in Xcode in my M1 Mac. Fortunately, it had resolved after following these steps:
Install Rosetta2 & Homebrew in non-rosetta mode terminal from the following StackOverflow link
Add this brew to the PATH or you can CD into /usr/local/Homebrew/bin
and run ./brew install watchman
In XCode, Go to Target > Build Settings > Architectures > Exclude Architectures
. And add these two key-value pairs.
I was also facing this issue while building archive in Xcode in my M1 Mac. Fortunately, it had resolved after following these steps:
- Install Rosetta2 & Homebrew in non-rosetta mode terminal from the following StackOverflow link
- Add this brew to the PATH or you can CD into
/usr/local/Homebrew/bin
and run./brew install watchman
Hi Salim95,
Thanks for sharing!! Now I can archive in x code
just to reshare, the StackOverflow answer I follow is https://stackoverflow.com/a/64997047/14657391
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.
Has anyone been able to find a reliable fix for this yet? I am having the same issue, and tried so many different solutions, including the ones from this thread but had no luck at all.
I have posted this question on Stack Overflow with my particular circumstances but had no response, so would be forever grateful if anyone has a suggestion Question on Stack Overflow
If anyone has problems with apple m1, there is a solution that works to me first install apple command line: xcode-select --install then install watchman: brew install watchman That's all
I was also stuck in this error This works for me run this command globally
brew install watchman
arch -arm64 brew install watchman
in my case , downgrading node from v14 to v12 solved the issue
UNCHECKED
If you are running your terminal with "Open using Rosetta", then having Xcode "Open using Rosetta" must also be checked and vice versa. This way depending on how people install Watchman (either with arch -arm64 or otherwise) then everything should coalesce.
So, running terminal with "Open using Rosetta", then installing Watchman via arch -arm64 brew install watchman
, then running Xcode with "Open using Rosetta" should work.
hi @emaxedon i;ve tried your way but no luck
events.js:291 throw er; // Unhandled 'error' event ^
Error: EMFILE: too many open files, watch at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:168:28) Emitted 'error' event on NodeWatcher instance at: at NodeWatcher.checkedEmitError (/Users/lucius/www/tgp-mobile/gympod/node_modules/sane/src/node_watcher.js:143:12) at FSWatcher.emit (events.js:314:20) at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:174:12) { errno: -24, syscall: 'watch', code: 'EMFILE', filename: null }
still received this issue, anyone still having same problem with xcode 13?
UPDATE
export NODE_BINARY=/Users/[name]/.nvm/versions/node/v16.15.0/bin/node ../node_modules/react-native/scripts/react-native-xcode.sh
I was also facing this issue while building archive in Xcode in my M1 Mac. Fortunately, it had resolved after following these steps:
- Install Rosetta2 & Homebrew in non-rosetta mode terminal from the following StackOverflow link
- Add this brew to the PATH or you can CD into
/usr/local/Homebrew/bin
and run./brew install watchman
- In XCode, Go to
Target > Build Settings > Architectures > Exclude Architectures
. And add these two key-value pairs.
After several attempts using different methods I solved it by completely uninstalling anything Homebrew-related and using the method above to restore it. I also used NVM to install the latest node version (18.2), then used XCode NOT in Rosetta mode.
At some point I also cleared the caches with
cd ios && rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/\*; pod deintegrate; pod setup; pod install --repo-update
but I'm not sure if that was really necessary
Same problem here with the same version
2021.06.07.00
on an Apple Silicon Macbook (m1).But in my case, there is a slight nuance (I don't know if it's your case too @deepakverma4):
* If I run metro from a terminal running in Rosetta mode, with watchman installed using x86_64 brew (`/usr/local/Homebrew`), no problem to bundle my javascript files. * If I run metro from a regular terminal (without Rosetta mode), with watchman installed using arm64 brew (`/opt/homebrew`), I get the `EMFILE: too many open files` error
Knowing that I tried a lot of random things like increasing a lot the ulimit in:
* `Start Packager` XCode script * `Bundle React Native code` XCode script * In a terminal before running manually metro * In launchctl using `sudo launchctl limit maxfiles 65536 unlimited`
But nothing worked. :/
Have you solved this issue?
in my case, I just moved my rn project folder to the root folder or /users/{name}
The only thing that worked for me also was moving the project to the root folder!
Same problem here with the same version
2021.06.07.00
on an Apple Silicon Macbook (m1).But in my case, there is a slight nuance (I don't know if it's your case too @deepakverma4):
- If I run metro from a terminal running in Rosetta mode, with watchman installed using x86_64 brew (
/usr/local/Homebrew
), no problem to bundle my javascript files.- If I run metro from a regular terminal (without Rosetta mode), with watchman installed using arm64 brew (
/opt/homebrew
), I get theEMFILE: too many open files
errorKnowing that I tried a lot of random things like increasing a lot the ulimit in:
Start Packager
XCode scriptBundle React Native code
XCode script- In a terminal before running manually metro
- In launchctl using
sudo launchctl limit maxfiles 65536 unlimited
But nothing worked. :/
Thank you
@michaelraffin I'm not a RN developer, but facing errors with chokidar. Your comment helped me on a way to resolve my issue 😄
I was also stuck in this error This works for me run this command globally
brew install watchman
This works, thanks!
rm -rf node_modules && npm install -- > worked for me in android
I came across this error as well
This works for me
xcode-select --install
brew install watchman
thanks to the comments above!
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")
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
@Yandamuri This was the first action I did. Maybe you know I noticed that when I uninstall watchman via brew but xCode still generates this issue. Idk how it happens when there is no watchman installation on my computer at all. Probably watchman is dependency of jest (I saw it in package-lock.json) but why packager uses it instead of using brew installed watchman?? I confused completely
@Yandamuri It solved! But idk how. I just describe what I did to make watchman working as it was before these two terrible days of searching. Repeat one more time: noting from this thread helped me (and from another threds in react-native, articles from the internet etc).
PS: I really don't know how these wired steps lead me to the correct result. Maybe somebody clever could explain what happend.
@gigby Let me explain what happened in my case
First, I was using node 14
in my machine and mobile app is running without any errors. Then I had to install node 12
for web version of mobile app and worked on web app only for few weeks. Then came back to mobile app to check some production issue and got the error when I ran the app. Then I removed node_modules
and installed once again. Then Issue got resolved.
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 :)
I was encountering this error while attempting to run a local Ember dev server on a new M1 Max. My issue was related to ~/Library/LaunchAgents
being owned by root
instead of my current user. I realized this after running watchman watch-project /path/to/my/project
and observing the error [cli] Failed to open /Users/<your_user>/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied
. Verify both ~/Library
and ~/Library/LaunchAgents
are owned by your user.
watchman watch-project /path/to/your/project
# Permissions error
[cli] Failed to open /Users/<your_user>/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied
# check Library ownership
ls -ld ~/Library
# root owns Library
drwx------@ 87 root staff 2784 Jan 23 09:42 /Users/<your_user>/Library
# fix Library ownership
sudo chown $(id -u) ~/Library
# check LaunchAgents ownership
ls -ld ~/Library/LaunchAgents
# root owns LaunchAgents
drwxr-xr-x@ 4 root staff 128 Jan 26 09:05 /Users/<your_user>/Library/LaunchAgents
# fix LaunchAgents ownership
sudo chown $(id -u) ~/Library/LaunchAgents
After fixing ownership of those directories, I no longer observed the EMFILE: too many open files
error, was prompted by the OS to grant watchman
access to the directory containing my project, and things worked as expected.
Thanks to @techniqs, I fixed my issue by adding export PATH=/opt/homebrew/bin:$PATH
in the Build Phases > Bundle React Native code & images section.
NOTE: Using RN: 0.71.3
set -e
export PATH=/opt/homebrew/bin:$PATH <---- add this line here
WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
The reason is that Xcode runs a clean shell for build tasks, so any PATH updates done in your profile (e.g. ~/.zshrc
) are not sourced and therefore Xcode cannot see the binaries installed via brew (in /opt/homebrew/bin
)
This Work for Me
https://stackoverflow.com/a/70177808/6455789
just add this line only
The same worked for me. I did have that issue when archiving the target.
brew install watchman
on Mac M1 solved the issue for me. Did not have to specify the arch.
This Work for Me
https://stackoverflow.com/a/70177808/6455789
just add this line only
I tried every single other possible fix, and this was the only thing that worked for me.
This Work for Me
https://stackoverflow.com/a/70177808/6455789
just add this line only
Yes, this solution saved my world!
Thanks to @techniqs, I fixed my issue by adding
export PATH=/opt/homebrew/bin:$PATH
in the Build Phases > Bundle React Native code & images section.NOTE: Using RN:
0.71.3
set -e export PATH=/opt/homebrew/bin:$PATH <---- add this line here WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh" /bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
The reason is that Xcode runs a clean shell for build tasks, so any PATH updates done in your profile (e.g.
~/.zshrc
) are not sourced and therefore Xcode cannot see the binaries installed via brew (in/opt/homebrew/bin
)
Wow, so thats the reason why "too many files" issue reoccurred after Xcode being updated in my case!! Good to know that, finally relieved! :D
I fixed it on my Macbook Sonoma M1 reinstalling watchman
like this:
$ arch -x86_64 brew install watchman
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 dobrew 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 toTarget -> Build Phases -> Bundle React Native code and images
and added a linewatchman --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 solution worked for me thanku bro
I had same issue last night and after researching many hours, I finally got the solution:
Reinstalling watchman solves it, although I was on the latest version. Keeping this here for reference: brew reinstall watchman
Thank me later :)
@rohithanss - I'll thank you right now! It fixed the issue for me :-)
For m1, and m2, just run sudo launchctl limit maxfiles 16384 16384 && ulimit -n 16384 And the problem will be solved
I was also facing this issue while building archive in Xcode in my M1 Mac. Fortunately, it had resolved after following these steps:
- Install Rosetta2 & Homebrew in non-rosetta mode terminal from the following StackOverflow link
- Add this brew to the PATH or you can CD into
/usr/local/Homebrew/bin
and run./brew install watchman
- In XCode, Go to
Target > Build Settings > Architectures > Exclude Architectures
. And add these two key-value pairs.
Thanks a lot) I removed standart homebrew and followed-up your steps. It works!!!!)))
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 dobrew 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 toTarget -> Build Phases -> Bundle React Native code and images
and added a linewatchman --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 :)
Thank you. This work for me after 2 days 👍
I faced the same issue today with the actual versions of watchman, node, Xcode, etc. The problem was in that I have had issues with the trunk repo and have temporarily added cocoapods repo that copies the whole huge pods list to local file system. Simply removing the cocoapods repo and reinstalling pods from trunk repo fixed the issue:
pod repo remove cocoapods
i'm facing below issue while generating archive in xcode
i'm on
2021.06.07.00
version of watchmanany idea how to fix this?