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

pod install not working #12407

Open
ndevev opened this issue Jun 11, 2024 · 13 comments
Open

pod install not working #12407

ndevev opened this issue Jun 11, 2024 · 13 comments

Comments

@ndevev
Copy link

ndevev commented Jun 11, 2024

Command

/usr/local/bin/pod install

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.15.2
        Ruby : ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
    RubyGems : 3.0.3.1
        Host : macOS 14.5 (23F79)
       Xcode : 15.4 (15F31d)
         Git : git version 2.39.3 (Apple Git-146)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

Error

REXML::ParseException - #<TypeError: wrong argument type String (expected Regexp)>
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/source.rb:220:in `scan'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/source.rb:220:in `match'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/baseparser.rb:227:in `pull_event'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/baseparser.rb:207:in `pull'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:23:in `parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:448:in `build'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:101:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `new'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `from_s'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:66:in `new_from_xcworkspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:102:in `create_workspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:71:in `integrate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:929:in `block in integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:925:in `integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:185:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
...
wrong argument type String (expected Regexp)
Line: 1
Position: 38
Last 80 unconsumed characters:
<?xml version="1.0" encoding="UTF-8"?>
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:96:in `rescue in parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:21:in `parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:448:in `build'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:101:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `new'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `from_s'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:66:in `new_from_xcworkspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:102:in `create_workspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:71:in `integrate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:929:in `block in integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:925:in `integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:185:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
@f-pennacchio
Copy link

I have the exact issue; trying to recompile and build a project for customer after clean mac sonoma install ad installing xcode 15.4

Stack

   CocoaPods : 1.11.3
        Ruby : ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin23]
    RubyGems : 3.0.1
        Host : macOS 14.4.1 (23E224)
       Xcode : 15.4 (15F31d)
         Git : git version 2.39.3 (Apple Git-146)
Ruby lib dir : /Users/Stefano/.rbenv/versions/2.6.0/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Error

REXML::ParseException - #<TypeError: wrong argument type String (expected Regexp)>

@f-pennacchio
Copy link

The issue seems to be related to rexml: ruby/rexml#142
rexml has been updated to fix the issue in new version 3.3.0
I don't know how to force cocoapods to use new library version, can someone please indicate how to do it?

@ndevev

@anusha-chromosis
Copy link

I am also having same exact issue ,have been trying this for hours

@f-pennacchio
Copy link

@ndevev @anusha-chromosis
I managed to complete pod install. Here the steps:

  • clone https://github.com/CocoaPods/Xcodeproj
  • edit Gemfile.lock and xcodeproj.gemspec changing rexml version to 3.3.0
  • run rake build
  • run gem install rexml -v 3.3.0 (I did this with and without sudo)
  • run gem install --local pkg/xcodeproj-1.24.0.gem (I did this with and without sudo)
  • running again pod install in project folder and now completes normally

@kou
Copy link

kou commented Jun 11, 2024

CocoaPods/Xcodeproj#944 will solve this.

@kou
Copy link

kou commented Jun 11, 2024

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan

@arturoacsan
Copy link

arturoacsan commented Jun 12, 2024

The context of my problem was that I was getting the error while running a Flutter app with plugins. The default one didn't gave me any problem. Also, I was getting the exact same issue that the original issue poster, same Ruby version, same lines, etc., but on an M1 device.

In my situation, the problem was solve once I removed cocoapods completely and then installed it again.
I'm a new MacOS user so I think this was my fault while trying to configure my environment.

I remove it using:
$ brew uninstall cocoapods

But I was still getting a result while executing:
$ pod --version

Then I use:
$ which pod

To find the path of the pods installation that was still on the computer.

So I executed:
sudo rm /usr/local/bin/pod

Then I run pod --version to make sure it was completely deleted. I installed it again using:
$ brew install cocoapods

Then I run the app again and it worked.
Hope this helps someone.

@ndevev
Copy link
Author

ndevev commented Jun 14, 2024

It happened when I was trying to set up a new MacBook Air. I couldn't solve it so I went back to the factory default and then migrated everything from my old one. And this worked well. So I can't send the gem list.
Anyway, thanks to everyone, the suggestions here will come in handy later.

@xiaodi0003
Copy link

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan

great, thx

@monfresh
Copy link

The reason you're seeing this error is because you're using the system Ruby (the Ruby version that came preinstalled on your Mac), or a version of Ruby older than 3.x that you installed yourself. Instead, I highly recommend using a version manager (such as chruby, rbenv, asdf) to install a newer and separate Ruby version that won't have this rexml issue.

The solutions offered here so far might work, but they are far from ideal, and can cause other issues. I've written popular articles that explain Why You Should Never Use sudo to Install Ruby Gems and Why You Shouldn't Use the System Ruby to Install Gems on a Mac.

To understand why this REXML error happens with older Ruby versions, and how to properly install a newer version of Ruby, read my latest article: How to fix REXML::ParseException TypeError in Cocoapods.

@Sabir-Islam-Khan
Copy link

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan

Thanks man. This solution worked for me.

@thevenice
Copy link

@ndevev @anusha-chromosis I managed to complete pod install. Here the steps:

  • clone https://github.com/CocoaPods/Xcodeproj
  • edit Gemfile.lock and xcodeproj.gemspec changing rexml version to 3.3.0
  • run rake build
  • run gem install rexml -v 3.3.0 (I did this with and without sudo)
  • run gem install --local pkg/xcodeproj-1.24.0.gem (I did this with and without sudo)
  • running again pod install in project folder and now completes normally

Worked for me thanks.

@ankushkushwaha
Copy link

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan

This solution really worked. Thanks man.

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

No branches or pull requests

10 participants