任何 pod 和 gem 命令都会导致 "Invalid gemspec" 错误

Any pod and gem command results in "Invalid gemspec" error

在我的 Flutter 项目中,我安装了一些 Firebase 插件,在 运行 将应用程序安装到 iOS 设备之前,我想更新 CocoaPods。

命令

/usr/local/bin/pod setup

举报

  1. pod repo update -> 成功完成
Updating spec repo `trunk`
  1. sudo gem install cocoapods -> 成功完成
Successfully installed cocoapods-1.11.2
Parsing documentation for cocoapods-1.11.2
Done installing documentation for cocoapods after 1 seconds
1 gem installed
  1. pod setup -> 发生错误
Invalid gemspec in [/Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec]: /Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec:74: syntax error, unexpected end, expecting end-of-input
    end
    ^~~
Invalid gemspec in [/Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec]: /Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec:74: syntax error, unexpected end, expecting end-of-input
    end
    ^~~
Invalid gemspec in [/Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec]: /Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec:74: syntax error, unexpected end, expecting end-of-input
    end
    ^~~

堆栈

   CocoaPods : 1.10.1
        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]
    RubyGems : 3.2.33
        Host : macOS 12.1 (21C52)
       Xcode : 13.2.1 (13C100)
         Git : git version 2.23.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

插件


错误

NoMethodError - undefined method `name' for nil:NilClass
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1105:in `block in _latest_specs'
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1102:in `reverse_each'
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1102:in `_latest_specs'
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1089:in `latest_specs'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:74:in `plugin_gems_for_prefix'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command/plugin_manager.rb:30:in `load_plugins'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:326:in `block in run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:325:in `each'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:325:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:25:in `load'
/usr/local/bin/pod:25:in `<main>'

flutter doctor -v 说:

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ✗ CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

pod repo update -> sudo gem install cocoapods 之后,任何 podgem 命令都会导致相同的错误,所以我不能 运行 甚至 [=29] =] 重新安装 CocoaPods。我该如何解决这个问题?

此问题已通过删除 /Library/Ruby/Gems/2.6.0/specifications/cocoapods-1.11.2.gemspec 解决,其中出现语法错误。
此文件在 pod repo updated.

时会崩溃

然后,我重新安装了cocoapods。

sudo gem uninstall cocoapods
sudo gem install cocoapods

此外,我必须从控制台启动 Android Studio,正确解析 PATH。

open /Applications/Android\ Studio.app