expo: `pod install` fails with `use_expo_modules!`

Summary

I’ve created a new expo app by doing npx create-expo-app test-app

Then in the app, I did expo run:ios to launch iOS simulator. Yet, it fails with pod install, erroring with the following message.

expo run:ios

⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: undefined method `exists?' for File:Class.

 #  from /Users/andrew/deepeyes/test-app/ios/Podfile:13
 #  -------------------------------------------
 #  target 'testapp' do
 >    use_expo_modules!
 #    config = use_native_modules!
 #  -------------------------------------------

What platform(s) does this occur on?

iOS

SDK Version

47.0.11

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.0 Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm Watchman: 2023.01.02.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.10.2 - /Users/andrew/.rubies/ruby-3.2.0/bin/pod IDEs: Xcode: /undefined - /usr/bin/xcodebuild npmPackages: expo: ~47.0.9 => 47.0.11 react: 18.1.0 => 18.1.0 react-native: 0.70.5 => 0.70.5 Expo Workflow: bare

Minimal reproducible example

  1. Create a new app: npx create-expo-app test-app
  2. Run the command: expo run:ios

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 34 (7 by maintainers)

Most upvoted comments

I had another issue with ruby installed with brew. My workaround was to install ruby with chruby and ruby-install. ruby 3.1.3 is the version without XCode 14 issue.

brew install chruby
brew install ruby-install

ruby-install ruby 3.1.3

Then you have to update your ~/.zshrc with the following.

source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh
chruby ruby-3.1.3

Then install cocoapods. I didn’t have to use sudo

gem install cocoapods

It finally worked for me.

@brentvatne

you likely have an old version of cocoapods installed. version 1.10.0 or later is required

please re-open this, this is a major issue and needs to be addressed ASAP.

Got the same issue

All new builds on IOS are currently broken.

  1. M1 macs suggest brew install of cocoapods (instead of gem)
  2. Brew installs of cocoapods require the latest ruby (since brew switch was deprecated) https://github.com/Homebrew/homebrew-core/blob/master/Formula/cocoapods.rb
  3. The latest ruby does not support the exists? function

It’s currently impossible for any new people to setup a new react native ios project.

@brentvatne Please reopen the issue.

That worked:

brew install ruby@3.1
echo 'export PATH="/opt/homebrew/opt/ruby@3.1/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
gem install cocoapods
echo 'export PATH="/opt/homebrew/lib/ruby/gems/3.1.0/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Or more simply, for current shell only:

brew install ruby@3.1
export PATH="/opt/homebrew/opt/ruby@3.1/bin:$PATH"
gem install cocoapods
export PATH="/opt/homebrew/lib/ruby/gems/3.1.0/bin:$PATH"

Here is the work around if don’t have time to wait on a fix

1. `brew install ruby@3.1`

2. Add that ruby@3.1 to path (At the front)

3. `gem install cocoapods`

4. `gem env` find the EXECUTABLE_DIRECTORY for the gem env

5. put result from 4 in path

Thank you! It works. You are Genius!

As a hint for someone who is not familiar (as I was as a new mac user) and using default homerew and shell settings:

  1. brew install ruby@3.1
  2. echo ‘export PATH=“/opt/homebrew/opt/ruby@3.1/bin:$PATH”’ >> ~/.zshrc
  3. gem install cocoapods
  4. echo ‘export PATH=“/opt/homebrew/lib/ruby/gems/3.1.0/bin:$PATH”’ >> ~/.zshrc

you likely have an old version of cocoapods installed. version 1.10.0 or later is required

Here is the work around if don’t have time to wait on a fix

  1. brew install ruby@3.1
  2. Add that ruby@3.1 to path (At the front)
  3. gem install cocoapods
  4. gem env find the EXECUTABLE_DIRECTORY for the gem env
  5. put result from 4 in path

@darrylyoung I asked the gesture handler team to release that fix, they might be able to release it today 😉

I’ve just published a fix in expo@47.0.13. Let me know if that works for you 😉 And thank you @KiwiKilian for submitting a PR for this 🙏

Need to remove ruby and cocoapods before running this: brew uninstall ruby cocoapods

And then this was working

Here is the work around if don’t have time to wait on a fix

  1. brew install ruby@3.1
  2. Add that ruby@3.1 to path (At the front)
  3. gem install cocoapods
  4. gem env find the EXECUTABLE_DIRECTORY for the gem env
  5. put result from 4 in path

Here is the diff if someone wants to PR this

diff --git a/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/DirMock.rb b/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/DirMock.rb
index 9c7a91328a..5f90b9c90e 100644
--- a/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/DirMock.rb
+++ b/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/DirMock.rb
@@ -20,7 +20,7 @@ class Dir
     # Remember to invoke `reset` after the test.
     def self.exist?(path)
         if !@@is_testing
-            return exists?(path)
+            return exist?(path)
         end
 
         @@exist_invocation_params.push(path)
diff --git a/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/FileMock.rb b/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/FileMock.rb
index dc1ebee239..823c7dc078 100644
--- a/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/FileMock.rb
+++ b/ios/versioned-react-native/ABI47_0_0/ReactNative/scripts/cocoapods/__tests__/test_utils/FileMock.rb
@@ -32,7 +32,7 @@ class File
     # Remember to invoke `reset` after the test.
     def self.exist?(path)
         if !@@is_testing
-            return exists?(path)
+            return exist?(path)
         end
 
         @@exist_invocation_params.push(path)
diff --git a/packages/expo-modules-autolinking/scripts/ios/xcode_env_generator.rb b/packages/expo-modules-autolinking/scripts/ios/xcode_env_generator.rb
index 9099ac5f31..51b4bce790 100644
--- a/packages/expo-modules-autolinking/scripts/ios/xcode_env_generator.rb
+++ b/packages/expo-modules-autolinking/scripts/ios/xcode_env_generator.rb
@@ -5,7 +5,7 @@ require 'pathname'
 def maybe_generate_xcode_env_file!()
   project_directory = Pod::Config.instance.project_root
   xcode_env_file = File.join(project_directory, '.xcode.env.local')
-  if File.exists?(xcode_env_file)
+  if File.exist?(xcode_env_file)
     return
   end

In my case, I am using homebrew ruby & cocoapods. However, the latest version is updated to “3.2”. The version removed deprecated ‘exist’ method. So, I changed default ruby (2.6) & cocoapods with gem. This resolved the issue.

Similar issue: https://www.linuxquestions.org/questions/slackware-14/error-in-compilation-of-mkvtoolnix-73-0-0-a-4175720454/

I mangeded to fix it by installing cocoapods via gem install cocoapods --user-install instead of homebrew

@dsincariuc have you seen my comment here https://github.com/expo/expo/issues/20707#issuecomment-1377916529 ? You need expo package to be at least 47.0.13.

None of the solutions above worked for me. I don’t use expo but having the same issue on m1 chip.

It’s now working for me, but only when I manually do the proposed change in this react-native-gesture-handler PR. I know that’s an issue with the other package, though. From an Expo point of view, it seems like it’s solved. Thank you, @tsapeta!

For context, this is the issue I’m still getting on 47.0.13 until I make the other change:

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

Also, I’m using the standard macOS Ruby install:

ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

@tsapeta I just switched from 47.0.12 to 47.0.13 and it indeed fixed this issue for me

ps: arm64 M1 / macOs Ventura 13.1

same here

This issue should be re-opened: Attemping to build a fresh expo project fails under ruby 3.2.

This seems to be because File.exists? was removed in Ruby 3.2. Here is the same issue rearing its head on a different/similar product: https://github.com/flutter/flutter/issues/109385