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

Pod install failing due to undefined 'exists' method at RNGestureHandler.podspec file #2367

Closed
ArunGovil opened this issue Jan 9, 2023 · 20 comments · Fixed by #2368
Closed
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@ArunGovil
Copy link

Description

Pod install keeps failing due to an undefined 'exists' method at RNGestureHandler.podspec file.

However the app works fine on Android, facing this error whenever I'm trying to run on ios environment.

I have checked with two of my other apps, where also I'm getting the same issue.

Here's the error log when running pod install:

[!] Invalid `Podfile` file:
[!] Invalid `RNGestureHandler.podspec` file: undefined method `exists?' for File:Class.

 #  from /Users/user/Development/QuickMark/node_modules/react-native-gesture-handler/RNGestureHandler.podspec:5
 #  -------------------------------------------
 #
 >  isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
 #  if isUserApp
 #  -------------------------------------------
.

 #  from /Users/user/Development/QuickMark/ios/Podfile:8
 #  -------------------------------------------
 #  target 'quickmark' do
 >    config = use_native_modules!
 #
 #  -------------------------------------------

Steps to reproduce

  1. cd ios
  2. pod install

Snack or a link to a repository

https://github.com/ArunGovil/QuickMark

Gesture Handler version

2.8.0

React Native version

0.70.6

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 14

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: iOS This issue is specific to iOS labels Jan 9, 2023
@official-ravi
Copy link

@ArunGovil have you got any solution for this issue? I am also facing the same issue after upgrading to latest MAC OS

@Acetyld
Copy link

Acetyld commented Jan 9, 2023

Same problem here, seems like a unkown issue so far. Anyone got a temp fix? (also running newest ventura)

@lotfi-a
Copy link

lotfi-a commented Jan 9, 2023

same problem here :(

@devoutDisciple
Copy link

Same problem here

@aqweider
Copy link

aqweider commented Jan 9, 2023

We have same issue here

@beebop1032
Copy link

Same here

@j-piasecki
Copy link
Member

Before #2368 gets released, this patch should do the trick:

diff --git a/RNGestureHandler.podspec b/RNGestureHandler.podspec
index fed3e8aea..fc3226de1 100644
--- a/RNGestureHandler.podspec
+++ b/RNGestureHandler.podspec
@@ -2,7 +2,7 @@ require "json"
 
 fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
 
-isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
+isUserApp = File.exist?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
 if isUserApp
   libInstances = %x[find ../../ -name "package.json" | grep "/react-native-gesture-handler/package.json" | grep -v "/.yarn/"]
   libInstancesArray = libInstances.split("\n")

@witcherlin
Copy link

As a workaround, if you have cocoapods installed via brew, you can patch the ruby version in the brew formula:

  1. Open a formula in vscode (for example)
HOMEBREW_EDITOR=code brew edit cocoapods
  1. Replace ruby with ruby@2.7 in lines 21 and 24 and save
19 | ...
20 |  uses_from_macos "libffi", since: :catalina
21 |  uses_from_macos "ruby@2.7", since: :catalina
22 |
23 |  on_arm do
24 |   depends_on "ruby@2.7"
25 |  end
26 | ...
  1. Reinstall cocoapods
brew reinstall --build-from-source cocoapods

In my case the problem was not only in this package, and this patch "solved" the problem for all packages.

@ArunGovil
Copy link
Author

@j-piasecki Thank you for responding, it did worked for gesture-handler.

However the issue was still coming up in other packages.

Followed the answer by @witcherlin which solved the issue completely.

Thanks everyone, closing the issue.

@Acetyld
Copy link

Acetyld commented Jan 9, 2023

As a workaround, if you have cocoapods installed via brew, you can patch the ruby version in the brew formula:

  1. Open a formula in vscode (for example)
HOMEBREW_EDITOR=code brew edit cocoapods
  1. Replace ruby with ruby@2.7 in lines 21 and 24 and save
19 | ...
20 |  uses_from_macos "libffi", since: :catalina
21 |  uses_from_macos "ruby@2.7", since: :catalina
22 |
23 |  on_arm do
24 |   depends_on "ruby@2.7"
25 |  end
26 | ...
  1. Reinstall cocoapods
brew reinstall --build-from-source cocoapods

In my case the problem was not only in this package, and this patch "solved" the problem for all packages.

For me this sadly didint work.
I keep getting

Error: Failure while executing; `code /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/cocoapods.rb /opt/homebrew/Library/Taps/homebrew/homebrew-cask/Casks/cocoapods.rb` exited with 1

When executing the: HOMEBREW_EDITOR=code brew edit cocoapods

As a workaround, if you have cocoapods installed via brew, you can patch the ruby version in the brew formula:

  1. Open a formula in vscode (for example)
HOMEBREW_EDITOR=code brew edit cocoapods
  1. Replace ruby with ruby@2.7 in lines 21 and 24 and save
19 | ...
20 |  uses_from_macos "libffi", since: :catalina
21 |  uses_from_macos "ruby@2.7", since: :catalina
22 |
23 |  on_arm do
24 |   depends_on "ruby@2.7"
25 |  end
26 | ...
  1. Reinstall cocoapods
brew reinstall --build-from-source cocoapods

In my case the problem was not only in this package, and this patch "solved" the problem for all packages.

Never mind! Fixed, i used brew edit cocaopods ^_^

@KiwiKilian
Copy link

@witcherlin ruby@3.1 also works, the problem only occurs with the latest ruby@3.2.

@witcherlin
Copy link

@KiwiKilian, yes, you are right, but I chose the version recommended in the react-native documentation, currently 2.7.6

@dcsan
Copy link

dcsan commented Jan 12, 2023

anyone know why the latest ruby is even used? i thought the pods installer was using system ruby?

@elmargasimov
Copy link

I solved it by installing a version manager for Ruby (rbenv in my case, but you can use rvm too). I had cocoapods installed with brew previously, I removed this by running brew uninstall cocoapods. Then installed ruby version 3.1.0 with rbenv (rbenv install 3.1.0). Then ran gem install cocoapods. Works fine now.

@yolpsoftware
Copy link

Uhm, thanks for the workaround and fix, but why does a deprecated method break the whole thing? Seems to me the point of a "deprecation" is exactly to warn devs that this method might be removed in a later version, so they can adapt before the pipelines of all the non-Ruby people are broken 🤷🏻‍♂️

@iway1
Copy link

iway1 commented Jan 31, 2023

ruby likes to release breaking changes in minor versions, not sure why they don't respect semver.

@MahmoudAziz1996
Copy link

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 :)

@rikur
Copy link

rikur commented Jan 15, 2024

Fixed in latest release of react-native-gesture-handler.

"resolutions": {
    "react-native-gesture-handler": "2.14.1"
  },

@erTongWang
Copy link

Before #2368 gets released, this patch should do the trick:

diff --git a/RNGestureHandler.podspec b/RNGestureHandler.podspec
index fed3e8aea..fc3226de1 100644
--- a/RNGestureHandler.podspec
+++ b/RNGestureHandler.podspec
@@ -2,7 +2,7 @@ require "json"
 
 fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
 
-isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
+isUserApp = File.exist?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
 if isUserApp
   libInstances = %x[find ../../ -name "package.json" | grep "/react-native-gesture-handler/package.json" | grep -v "/.yarn/"]
   libInstancesArray = libInstances.split("\n")

This is a viable approach

@j-piasecki
Copy link
Member

FYI: #2368 was released in 2.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.