Cli: Cannot install Pods when init App

Created on 3 Oct 2019  ยท  8Comments  ยท  Source: react-native-community/cli

Environment

System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz
Memory: 24.54 MB / 4.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.10.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 22, 23, 25, 26, 27, 28
Build Tools: 23.0.1, 26.0.1, 26.0.2, 27.0.3, 28.0.3
System Images: android-26 | Google APIs Intel x86 Atom_64
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Description

When i run command

npx react-native init MyApp
Process ended with error:

Info All dependencies
โ”œโ”€ @babel/[email protected]
โ”œโ”€ @babel/[email protected]
โ”œโ”€ @react-native-community/[email protected]
โ”œโ”€ @types/[email protected]
โ”œโ”€ @types/[email protected]
โ”œโ”€ @typescript-eslint/[email protected]
โ”œโ”€ @typescript-eslint/[email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ””โ”€ [email protected]
โœจ  Done in 24.13s.
info Installing required CocoaPods dependencies

[!] Invalid `Podfile` file: cannot infer basepath.

 #  from /works/MyApp/ios/Podfile:2
 #  -------------------------------------------
 #  platform :ios, '9.0'
 >  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #
 #  -------------------------------------------

(node:33132) UnhandledPromiseRejectionWarning: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./MyApp/ios && pod install".
CocoaPods documentation: https://cocoapods.org/
    at installPods (/works/MyApp/node_modules/@react-native-community/cli/build/tools/installPods.js:157:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:33132) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:33132) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

In ../node_modules/@react-native-community/cli-platform-ios/ i cannot find directory native_modules

pod --version
1.8.1

Reproducible Demo

It's reproduce on my PC

bug report needs repro

Most helpful comment

I got this same error and the problem was the version of Ruby I was using when running pod install. I had been using Ruby v2.1.0 (same as issue author above). Upgrading to Ruby v2.4.1 fixed the issue (require_relative was not supported in eval'd files in 2.1.0).

All 8 comments

Are you using Yarn workspaces? Can you verify that node_modules/@react-native-community/cli-platform-ios is a valid path?

Looks like either something is missing in your node_modules or you're using a monorepo and packages were hoisted.

Also, have you tried running:

Please try again manually: "cd ./MyApp/ios && pod install".

as per the debugging info?

@grabbou

Are you using Yarn workspaces?

How i can check this?

node_modules/@react-native-community/cli-platform-ios is a valid path?

I think yes, because i see this path and files:
LICENSE build native_modules.rb package.json

you're using a monorepo and packages were hoisted.

How i can check this?

Also, have you tried running:
Please try again manually: "cd ./MyApp/ios && pod install".

MacBook-Air:tests admin$ cd ./MyApp/ios && pod install --verbose

[!] Invalid `Podfile` file: cannot infer basepath.

 #  from /works/tests/MyApp/ios/Podfile:2
 #  -------------------------------------------
 #  platform :ios, '9.0'
 >  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #
 #  -------------------------------------------

/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:301:in `rescue in block in from_ruby'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:295:in `block in from_ruby'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:50:in `instance_eval'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:50:in `initialize'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:293:in `new'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:293:in `from_ruby'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-core-1.8.1/lib/cocoapods-core/podfile.rb:259:in `from_file'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.8.1/lib/cocoapods/config.rb:200:in `podfile'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.8.1/lib/cocoapods/command.rb:150:in `verify_podfile_exists!'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.8.1/lib/cocoapods/command/install.rb:46:in `run'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.8.1/lib/cocoapods/command.rb:52:in `run'
/Users/admin/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.8.1/bin/pod:55:in `<top (required)>'
/Users/admin/.rbenv/versions/2.1.0/bin/pod:23:in `load'
/Users/admin/.rbenv/versions/2.1.0/bin/pod:23:in `<main>'
MacBook-Air:ios admin$

I think problem that Pod cannot find pods in cli-platform-ios/native_modules But i don't know Pods(native iOS libs ) are already builded in repo, or i need run build step for Pods. If second, so how i can run this step?

Please update the @react-native-community/cli to the latest version.

update gem xcodeproj gem
#487 (comment)

Sorry, but it's not my situation.

MacBook-Air:iOS admin$ gem update xcodeproj
Updating installed gems
Nothing to update

Please update the @react-native-community/cli to the latest version.

with โ””โ”€ @react-native-community/[email protected] same error.

MacBook-Air:MyApp admin$ cd iOS
MacBook-Air:iOS admin$ pod install

[!] Invalid `Podfile` file: cannot infer basepath.

 #  from /works/Tests/test2/MyApp/ios/Podfile:2
 #  -------------------------------------------
 #  platform :ios, '9.0'
 >  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 #
 #  -------------------------------------------

Thanks. Can you setup a minimal repro which we could investigate?

@thymikee Hi!
I remove "global" cache (in home dir ) for all components: npm, yarn, cocoapod. In other words i leave only binaries, than i upgrade all binaries - brew, cocoapod, npm etc.

And now i can init RN app 0.61, with cli 3.0-alpha without errors.

Thank you.

I got this same error and the problem was the version of Ruby I was using when running pod install. I had been using Ruby v2.1.0 (same as issue author above). Upgrading to Ruby v2.4.1 fixed the issue (require_relative was not supported in eval'd files in 2.1.0).

Was this page helpful?
0 / 5 - 0 ratings