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

Cocoapods shows "undefined method `exists?' for File:Class" error #141167

Closed
sma opened this issue Jan 9, 2024 · 9 comments · Fixed by #141169
Closed

Cocoapods shows "undefined method `exists?' for File:Class" error #141167

sma opened this issue Jan 9, 2024 · 9 comments · Fixed by #141169
Assignees
Labels
a: build Building flutter applications with the tool a: plugins Support for writing, building, and running plugin packages c: regression It was better in the past than it is now P1 High-priority issues at the top of the work list platform-mac Building on or for macOS specifically team-ecosystem Owned by Ecosystem team tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@sma
Copy link

sma commented Jan 9, 2024

Steps to reproduce

I run flutter build macos on a project with native dependencies (Firebase) so that cocoapods needs to run. It used to work just fine, but now I'm getting the error message undefined method exists?' for File:Class. That method is called File.exists` in Ruby 3.2 … which is used by my version of cocoapods internally, so it seems. It might have started with Xcode 15.2 which I just installed, but I'm not sure.

I'm on Sonoma 14.2.1, using Homebrew 4.2.3, cocoapods 1.14.3 (which is dependent on Ruby 3.2.2 although this version isn't in the PATH) installed via brew install cocoapods, Xcode 15.2 and Flutter 3.18.0-19.0.pre.123

Expected results

It should run.

Actual results

[!] An error occurred while processing the post-install hook of the Podfile.

    undefined method `exists?' for File:Class

    /Users/sma/Work/flutter/packages/flutter_tools/bin/podhelper.rb:349:in `flutter_get_local_engine_dir'
    /Users/sma/Work/flutter/packages/flutter_tools/bin/podhelper.rb:131:in `flutter_additional_macos_build_settings'
    /Users/sma/Work/tellorium_poc/macos/Podfile:38:in `block (3 levels) in from_ruby'
    /Users/sma/Work/tellorium_poc/macos/Podfile:37:in `each'
    /Users/sma/Work/tellorium_poc/macos/Podfile:37:in `block (2 levels) in from_ruby'
    /usr/local/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-core-1.14.3/lib/cocoapods-core/podfile.rb:196:in
    `post_install!'
    /usr/local/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1013:in
    `run_podfile_post_install_hook'
...

Code sample

.

Screenshots or Video

.

Logs

.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.18.0-19.0.pre.123, on macOS 14.2.1 23C71 darwin-x64, locale de-DE)
    • Flutter version 3.18.0-19.0.pre.123 on channel master at /Users/sma/Work/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5f17badf41 (32 minutes ago), 2024-01-09 10:49:13 +0100
    • Engine revision 820645dbcc
    • Dart version 3.4.0 (build 3.4.0-4.0.dev)
    • DevTools version 2.31.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/sma/Library/Android/sdk
    • Platform android-34, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0

...

• No issues found!
@sma
Copy link
Author

sma commented Jan 9, 2024

I checked on another with the same configuration but still with Xcode 15.1 and it doesn't work, so Xcode 15.2 is not the cause for the problem :(

@TahaTesser
Copy link
Member

TahaTesser commented Jan 9, 2024

I was about to file this. This also reproduces for me in a new project when adding integration_test (My best guess is this reproduces when introducing a platform dependent package) on the master/main branch and running on the macOS platform (doesn't reproduce for iOS simulator)

Steps to reproduce

  1. flutter create myapp
  2. cd myapp and then run the app from an IDE or terminal (flutter run -d macos)
  3. This should work fine.
  4. Add the integration_test package for instance
dev_dependencies:
  flutter_test:
    sdk: flutter
+ integration_test:
+   sdk: flutter
  1. Run the app again on macOS platform (flutter run -d macos)

Logs

expand to view the logs
playground git:(main) ✗ fr -d macos
Downloading darwin-x64/FlutterMacOS.framework tools...              3.4s
Downloading darwin-x64/gen_snapshot tools...                     1,587ms
Downloading darwin-x64-profile/FlutterMacOS.framework tools...      2,210ms
Downloading darwin-x64-profile tools...                          1,289ms
Downloading darwin-x64-profile/gen_snapshot tools...             1,456ms
Downloading darwin-x64-release/FlutterMacOS.framework tools...      1,706ms
Downloading darwin-x64-release tools...                          1,199ms
Downloading darwin-x64-release/gen_snapshot tools...             1,383ms
Launching lib/main.dart on macOS in debug mode...
Running pod install...                                             526ms
CocoaPods' output:

      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
      Using `ARCHS` setting to build architectures of target `Pods-RunnerTests`: (``)

    Fetching external sources
    -> Fetching podspec for `FlutterMacOS` from `Flutter/ephemeral`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update

    Comparing resolved specification to the sandbox manifest
      A FlutterMacOS

    Downloading dependencies

    -> Installing FlutterMacOS (1.0.0)
      - Running pre install hooks
      - Running pre integrate hooks

    Generating Pods project
      - Creating Pods project
      - Installing files into Pods project
        - Adding source files
        - Adding frameworks
        - Adding libraries
        - Adding resources
        - Adding development pod helper files
        - Linking headers
      - Installing Pod Targets
        - Installing target `FlutterMacOS` macOS 10.14
      - Installing Aggregate Targets
        - Installing target `Pods-Runner` macOS 10.14
          - Generating Info.plist file at `Pods/Target Support Files/Pods-Runner/Pods-Runner-Info.plist`
          - Generating module map file at `Pods/Target Support Files/Pods-Runner/Pods-Runner.modulemap`
          - Generating umbrella header at `Pods/Target Support Files/Pods-Runner/Pods-Runner-umbrella.h`
          - Generating dummy source at `Pods/Target Support Files/Pods-Runner/Pods-Runner-dummy.m`
        - Installing target `Pods-RunnerTests` macOS 10.14
          - Generating Info.plist file at `Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-Info.plist`
          - Generating module map file at `Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.modulemap`
          - Generating umbrella header at `Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-umbrella.h`
          - Generating dummy source at `Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-dummy.m`
      - Generating deterministic UUIDs
      - Stabilizing target UUIDs
      - Running post install hooks
    [!] An error occurred while processing the post-install hook of the Podfile.

    undefined method `exists?' for File:Class

    /Users/tahatesser/Code/flutter/packages/flutter_tools/bin/podhelper.rb:349:in `flutter_get_local_engine_dir'
    /Users/tahatesser/Code/flutter/packages/flutter_tools/bin/podhelper.rb:131:in `flutter_additional_macos_build_settings'
    /Users/tahatesser/Projects/playground/macos/Podfile:41:in `block (3 levels) in from_ruby'
    /Users/tahatesser/Projects/playground/macos/Podfile:40:in `each'
    /Users/tahatesser/Projects/playground/macos/Podfile:40:in `block (2 levels) in from_ruby'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-core-1.14.3/lib/cocoapods-core/podfile.rb:196:in `post_install!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:149:in `message'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:307:in `generate_pods_project'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:183:in `integrate'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:170:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command/install.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/bin/pod:55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `<main>'

    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1015:in `rescue in run_podfile_post_install_hook'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1012:in `run_podfile_post_install_hook'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:149:in `message'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:307:in `generate_pods_project'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:183:in `integrate'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:170:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command/install.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/bin/pod:55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `<main>'

Error output from CocoaPods:

    Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3

Error: Error running pod installplayground git:(main) ✗ 

Flutter doctor

expand to view the flutter doctor -v results
playground git:(main) ✗ fd
[✓] Flutter (Channel main, 3.18.0-19.0.pre.104, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
    • Flutter version 3.18.0-19.0.pre.104 on channel main at /Users/tahatesser/Code/flutter
    • Upstream repository [email protected]:TahaTesser/flutter.git
    • FLUTTER_GIT_URL = [email protected]:TahaTesser/flutter.git
    • Framework revision 12720f0e51 (28 hours ago), 2024-01-08 01:53:21 -0500
    • Engine revision bbebee1465
    • Dart version 3.3.0 (build 3.3.0-279.0.dev)
    • DevTools version 2.31.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/tahatesser/Code/android-sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_SDK_ROOT = /Users/tahatesser/Code/android-sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 120.0.6099.199
    ! Error: Browsing on the local area network for Taha’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!playground git:(main) ✗ 

@TahaTesser
Copy link
Member

TahaTesser commented Jan 9, 2024

I checked on another with the same configuration but still with Xcode 15.1 and it doesn't work, so Xcode 15.2 is not the cause for the problem :(

That's right. I had Xcode 15.1 yesterday when I first reproduced this issue. Today after upgrading Xcode 15.2 the issue persists.

@sma
Copy link
Author

sma commented Jan 9, 2024

Could it be this change?

@sma
Copy link
Author

sma commented Jan 9, 2024

macos on master is broken, ios on master works. Both work on the latest beta (3.18.0-0.2.pre).

@stuartmorgan stuartmorgan added c: regression It was better in the past than it is now tool Affects the "flutter" command-line tool. See also t: labels. platform-mac Building on or for macOS specifically a: build Building flutter applications with the tool team-ecosystem Owned by Ecosystem team P1 High-priority issues at the top of the work list a: plugins Support for writing, building, and running plugin packages labels Jan 9, 2024
@stuartmorgan stuartmorgan self-assigned this Jan 9, 2024
auto-submit bot pushed a commit that referenced this issue Jan 9, 2024
The recently landed #140222 accidentally used the deprecated `exists?` instead of the non-deprecated `exist?` (which other code in this file is already, correctly, using).

Fixes #141167
stuartmorgan added a commit to stuartmorgan/flutter that referenced this issue Jan 11, 2024
The recently landed flutter#140222 accidentally used the deprecated `exists?` instead of the non-deprecated `exist?` (which other code in this file is already, correctly, using).

Fixes flutter#141167
auto-submit bot pushed a commit that referenced this issue Jan 11, 2024
Cherry picks #141169 to beta

The recently landed #140222 accidentally used the deprecated `exists?` instead of the non-deprecated `exist?` (which other code in this file is already, correctly, using).

See #141167
@sma
Copy link
Author

sma commented Jan 12, 2024

FYI, currently, not only the current master is broken but also the latest beta.

@liho00

This comment was marked as off-topic.

@pharshdev
Copy link

working on beta 3.19.0-0.2.pre

Copy link

github-actions bot commented Feb 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: build Building flutter applications with the tool a: plugins Support for writing, building, and running plugin packages c: regression It was better in the past than it is now P1 High-priority issues at the top of the work list platform-mac Building on or for macOS specifically team-ecosystem Owned by Ecosystem team tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants