react-native: Can't Init project - It won't install CocoaPods
Description
I have a brand new mac and am trying to initialise a new React Native project. However, it fails when trying to install CocoaPods:
✔ Downloading template ✔ Copying template ✔ Processing template ✔ Installing Ruby Gems ℹ Installing Ruby Gems ✖ Installing CocoaPods error ✖ Installing CocoaPods error An error occured while trying to install CocoaPods, which is required by this template. Please try again manually: sudo gem install cocoapods.
If I try to manually install Cocoapods as it suggests, it says:
Error installing cocoapods: There are no versions of cocoapods-downloader (>= 2.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you’re looking for? cocoapods-downloader requires Ruby version >= 2.7.4. The current ruby version is 2.6.10.210.
Do I have to update Ruby?
React Native Version
0.72.6
Output of npx react-native info
npx react-native info info Fetching system and libraries information… System: OS: macOS 14.1 CPU: (10) arm64 Apple M2 Pro Memory: 180.22 MB / 32.00 GB Shell: version: “5.9” path: /bin/zsh Binaries: Node: version: 21.1.0 path: /opt/homebrew/bin/node Yarn: Not Found npm: version: 10.2.1 path: /opt/homebrew/bin/npm Watchman: version: 2023.10.23.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: - DriverKit 23.0 - iOS 17.0 - macOS 14.0 - tvOS 17.0 - watchOS 10.0 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: version: 15.0.1/15A507 path: /usr/bin/xcodebuild Languages: Java: Not Found Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: “@react-native-community/cli”: Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.6 wanted: 0.72.6 react-native-macos: Not Found npmGlobalPackages: “react-native”: Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: Not found newArchEnabled: Not found
(node:21795) [DEP0040] DeprecationWarning: The punycode
module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ...
to show where the warning was created)
Steps to reproduce
npx react-native@latest init AwesomeProject
Snack, screenshot, or link to a repository
N/A
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 24 (8 by maintainers)
I tried above solution and doesn’t work.
sudo gem uninstall cocoapods -> Gem ‘cocoapods’ is not installed
sudo gem install cocoapods -> ERROR: Error installing cocoapods: There are no versions of cocoapods-downloader (>= 2.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you’re looking for? cocoapods-downloader requires Ruby version >= 2.7.4. The current ruby version is 2.6.10.210.
brew install cocoapods -> cocoapods 1.14.2 is already installed and up-to-date.
brew reinstall cocoapods. -> just reinstalled
pod: v1.14.2 gem: v3.0.3.1 node: v16.14.2 npm: v8.5.0
It works for me when I use brew install cocaopods Don’t follow sudo gem install cocoapods as it will keep throwing the same error
@tinymobile I’ve already fixed it
My steps to fix it type in terminal (bash)
sudo gem uninstall cocoapods sudo gem install cocoapods brew install cocoapods brew reinstall cocoapods
and run again npx react-native@latest init AwesomeProject
looks strange, but the main thing is that it solved the problem)
sudo gem uninstall cocoapods sudo gem install cocoapods brew install cocoapods brew reinstall cocoapods
Yes, this worked for me as well. Very strange! I’ll keep rebuilding my project to see if it causes any issues down the line, and let you know. Thanks!
I have the same Problem (macOS Sonoma 14.1.1) while executing
sudo gem install cocoapods
and I get the following error message:ERROR: Error installing cocoapods: There are no versions of cocoapods-downloader (>= 2.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for? cocoapods-downloader requires Ruby version >= 2.7.4. The current ruby version is 2.6.10.210.
It worked for the previous version of cocoapods. While executing the command I was asked to install a few other things, so the final order was:
sudo gem install drb -v 2.0.5
sudo gem install activesupport -v 6.1.7.6
sudo gem install cocoapods -v 1.13.0
Good luck 😃
@cipolleschi At the end I could figure out what was the problem.
I run
As you can see, It cannot symblink because
xcodeproj
already exists in the path/user/local/bin/xcodeproj
. So I had to remove it manually and then run brew link cocoapodsNitpick: I guess everything happened because I installed Xcode first (which install the comand line tools) and then
brew install cocoapods
(which also install the command line tools, maybe in a different path), but I’m not sure.