EAS build gives: Invalid `RNGestureHandler.podspec` file: undefined method `exists?'
Asked Answered
I

7

27

Recently, when I yarn eas build my expo project I have started failing with

[INSTALL_PODS] Using Expo modules
[INSTALL_PODS] [Expo] Enabling modular headers for pod ExpoModulesCore
...
[INSTALL_PODS] [!] Invalid `Podfile` file: 
[INSTALL_PODS] [!] Invalid `RNGestureHandler.podspec` file: undefined method `exists?' for File:Class.
...
[INSTALL_PODS]  #  -------------------------------------------
[INSTALL_PODS]  #  
[INSTALL_PODS]  >  isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
[INSTALL_PODS]  #  if isUserApp
[INSTALL_PODS]  #  -------------------------------------------

I don't build locally often (remote builds on the Expo servers do fine) so any number of things might have triggered this over the past several weeks, including a migration from an Intel MBP to an M2 MBA, but I wonder if there's an obvious reason that someone has experience with. The error suggests there's something wrong with the podfile's use of an undefined method. But the suggestions for addressing this I've found online involve all kinds of tweaking that are way beyond what I'm familiar with. My experience with Expo/EAS just been to be sure to

brew install cocoapods fastlane

and don't involve much more than that. Ideally I'd like to avoid messing with special gem installations of the sort suggested as quick fixes.

So the question is: is this indeed just a bug in a podfile (use of a deprecated method) that will eventually get fixed?


UPDATE: Broadly it seems that the answer is "yes": this does get fixed in later versions of the affected packages, but those packages are not officially compatible with Expo. If I update them to versions that allow building, then I get warnings:

[RUN_EXPO_DOCTOR] [16:17:37] Some dependencies are incompatible with the installed expo package version:
[RUN_EXPO_DOCTOR] [16:17:37]  - react-native-gesture-handler - expected version: ~2.8.0 - actual version installed: 2.9.0
[RUN_EXPO_DOCTOR] [16:17:37]  - react-native-reanimated - expected version: ~2.12.0 - actual version installed: 2.14.4

so the question becomes: when will Expo officially support package versions required to successfully build?

Iaea answered 13/2, 2023 at 20:47 Comment(0)
S
41

This issue happens because Ruby 3.2 removed deprecated function File.exists? (reference)

First remove node_modules, package-lock.json

Then install newer versions of both libraries

npm install react-native-gesture-handler@^2.9.0
npm install react-native-reanimated@^2.14.4

Then run cd ios and pod install.

Soinski answered 13/3, 2023 at 19:10 Comment(0)
U
11
  1. Install 2.9.0 of react-native-gesture-handler. source: comment
  2. Install 2.14.4 of react-native-reanimated. source: comment
  3. Remove node_modules, yarn.lock ios/Podfile.lock, ios/build, ios/Pods.
  4. yarn install && yarn ios.

I've also updated cocoa pods to the latest sudo gem install cocoapods.

Uzial answered 8/3, 2023 at 6:34 Comment(0)
S
9

install the new version for these libraries: react-native-gesture-handler & react-native-reanimated

npm install react-native-gesture-handler@^2.9.0
npm install react-native-reanimated@^2.14.4

then

pod install
Szczecin answered 2/5, 2023 at 15:48 Comment(0)
A
4

Ruby 3.2.0 removed File.exists?.

This issue was reported on the expo repo on GitHub.

The recommended fix is to upgrade to [email protected].

Aceves answered 13/2, 2023 at 20:58 Comment(5)
That's what I thought too but my package.json has: "expo": "^47.0.13"Iaea
Ensure that yarn install has been run and that the installed package is up to date, then check the extended comments on the GitHub issue for more information on downstream packages.Aceves
Also I've tried downgrading ruby, but that hasn't worked either. Maybe there's some cruft somewhere that's getting in the way?Iaea
Yes, I deleted the packages directory and ran yarn.Iaea
Got it to build by using package versions that Expo doesn't (officially) support. See updated question.Iaea
F
1

This solution worked for me (running Node v18.15 and Ruby v3.3.1 and my build with Yarn v1.22.19) but I had to do all of the following:

Upgraded these dependencies:

    "expo": "^47.0.14",
    "react-native-bootsplash": "4.3.2",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-reanimated": "~3.1.0",
    "react-native-safe-area-context": "4.5.1",
    "react-native-screens": "~3.20.0",

Had to dump all these files:

    yarn-lock.json
    /node_modules/
    /ios/podfile.lock
    /ios/build/
    /ios/Pods/
Flinch answered 20/4, 2023 at 19:37 Comment(0)
B
1

I didn't need to downgrade the packages and was able to compile on macOS Sonoma 14.1.1 .

I used RVM - Ruby Version Manager to install and use Ruby 3.1.4 (does not overwrite macOS standard Ruby version) to get Expo to compile with npx expo run:ios using the following package versions:

"react-native-gesture-handler": "^2.9.0"
"react-native-reanimated": "^3.3.0"

I installed RVM with the following command, because there's also a known issue related to openssl regarding the compilation of rubies, and I followed the solution presented on this comment on Github.

arch -x86_64 rvm install 3.1.4 --with-openssl-dir=/usr/local/opt/[email protected]

Berenice answered 19/11, 2023 at 21:14 Comment(0)
B
0

Remove ^ from package dot json for react native gesture handler

Then:

rm -rf node_modules
yarn install 
cd ios
pod install 

And after that your pod will work fine.

It woks fine for me :)

Bridgman answered 24/10, 2023 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.