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

react-native doctor crashes when it fails to find the default Podfile #1989

Closed
sbalay opened this issue Jun 28, 2023 · 5 comments · Fixed by #1998
Closed

react-native doctor crashes when it fails to find the default Podfile #1989

sbalay opened this issue Jun 28, 2023 · 5 comments · Fixed by #1998

Comments

@sbalay
Copy link
Contributor

sbalay commented Jun 28, 2023

Environment

System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 79.91 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /var/folders/sl/dfwlj7fj2d52x407gqdq2trm0000gn/T/yarn--1687965785454-0.3638992685366529/node
    Yarn: 1.22.19 - /var/folders/sl/dfwlj7fj2d52x407gqdq2trm0000gn/T/yarn--1687965785454-0.3638992685366529/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
    Watchman: 2023.06.12.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.1 - /Users/sebastianbalay/.gem/ruby/3.1.2/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK:
      API Levels: 28, 30, 33
      Build Tools: 30.0.2, 30.0.3, 33.0.0
      System Images: android-28 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-33 | Google APIs Intel x86_64 Atom, android-33 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.2 AI-222.4459.24.2221.10121639
    Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.6 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.8 => 0.71.8
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Description

When the Podfile doesn't exist or is renamed, the doctor command crashes with the following error:

TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at Object.getDiagnostics (/Users/user/project/node_modules/@react-native-community/cli-doctor/build/tools/healthchecks/xcodeEnv.js:59:8)

Reproducible Demo

In any react-native project, rename or remove the Podfile inside the iOS folder (i.e. mv ios/Podfile ios/Podfile.backup)

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Jul 4, 2023

Hello @sbalay, may I ask why you need to change the default file name?

@sbalay
Copy link
Contributor Author

sbalay commented Jul 4, 2023

Hey, thanks for getting back!

Actually, we don't even have an iOS folder. We removed it as our react-native app runs as a brownfield integration in an already existing app and we structured the project in a way where we don't have an ios or android folder.

@szymonrybczak
Copy link
Collaborator

Uhm, okay. I will try to adjust the doctor command to work in the brownfield setup, because right now we're using the static paths, see here:


but we can actually use paths specified in react-native.config.js.

@robhogan
Copy link
Collaborator

robhogan commented Jul 4, 2023

The offending reduce was already removed on main in b7954c9 - it looks like it should fail gracefully now? An "Xcode environment not found" warning (but doctor not crashing) seems like a good outcome here.

Might be worth picking that back to 11.x

@sbalay
Copy link
Contributor Author

sbalay commented Jul 4, 2023

Seems that the commit is already in v11.x

Screenshot 2023-07-04 at 10 51 23

We are currently relying on react-native 0.71.x that uses v10.x.x of the CLI: https://github.com/facebook/react-native/blob/0.71-stable/package.json#L113

After adding overrides to the package.json to point the CLI to v11.x.x this is the output I get:

npx react-native doctor
⠧ Running diagnostics...warn Command failed with exit code 1: ruby -e require "Bundler"; gemfile = Bundler::Definition.build("Gemfile", nil, {}); version = gemfile.ruby_version.engine_versions.join(", "); begin; gemfile.validate_runtime!; rescue Bundler::GemfileNotFound; puts "No Gemfile"; exit 1; rescue Bundler::RubyVersionMismatch; puts "Bundle invalid Ruby"; STDERR.puts version; exit 2; rescue => e; STDERR e.message; exit 3; else; puts "Ok"; STDERR.puts version; end
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/bundler/definition.rb:32:in `build': /Users/sebastianbalay/projects/faq-mini-1687270558430/Gemfile not found (Bundler::GemfileNotFound)
	from -e:1:in `<main>'
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ npm - Required to install NPM dependencies
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✖ JDK - Required to compile Java code
   - Version found: 1.8.0_292
   - Version supported: >= 11
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: 30.0.2, 30.0.3, 33.0.0
   - Version supported: Not Found
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ Ruby
 ✖ CocoaPods - Required for installing iOS dependencies
   - Version found: N/A
   - Version supported: >= 1.10.0
 ● ios-deploy - Required for installing your app on a physical device with the CLI
 ✓ .xcode.env - File to customize Xcode environment

Errors:   3
Warnings: 1

I guess this makes more sense and is something I can work with, so feel free to close the issue. However, using the paths defined in react-native.config.js as @szymonrybczak suggested would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants