react-native-gesture-handler: Pod install failing due to undefined 'exists' method at RNGestureHandler.podspec file
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
- cd ios
- 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
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 8
- Comments: 20 (2 by maintainers)
I solved it by installing a version manager for Ruby (
rbenv
in my case, but you can uservm
too). I hadcocoapods
installed withbrew
previously, I removed this by runningbrew uninstall cocoapods
. Then installed ruby version3.1.0
withrbenv
(rbenv install 3.1.0
). Then rangem install cocoapods
. Works fine now.As a workaround, if you have
cocoapods
installed viabrew
, you can patch the ruby version in the brew formula:ruby
withruby@2.7
in lines 21 and 24 and saveIn my case the problem was not only in this package, and this patch “solved” the problem for all packages.
Before #2368 gets released, this patch should do the trick:
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 🤷🏻♂️
ruby likes to release breaking changes in minor versions, not sure why they don’t respect semver.
anyone know why the latest ruby is even used? i thought the pods installer was using system ruby?
@KiwiKilian, yes, you are right, but I chose the version recommended in the react-native documentation, currently 2.7.6
Same problem here