ReactNative iOS执行pod install报错:找不到rexml gem依赖
解决M1 MacBook Pro上React Native iOS项目pod install报错(找不到rexml gem)
问题描述
2021款M1 MacBook Pro首次搭建React Native开发环境,运行iOS项目的pod install命令时触发Gem::MissingSpecError,提示找不到满足要求的rexml gem,导致模拟器运行时构建失败。
报错日志
`rescue in block in activate_dependencies': Could not find 'rexml' (>= 0) among 117 total gem(s) (Gem::MissingSpecError) Checked in 'GEM_PATH=/Users/craigsau/.rvm/gems/ruby-2.7.5:/Users/craigsau/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0:/opt/homebrew/Cellar/cocoapods/1.11.3/libexec' at: /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/specifications/CFPropertyList-3.0.5.gemspec, execute `gem env` for more information from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1398:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1405:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1405:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:286:in `block in activate_bin_path' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:285:in `synchronize' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:285:in `activate_bin_path' from /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `<main>'
Could not find 'rexml' (>= 0) among 117 total gem(s) (Gem::MissingSpecError) Checked in 'GEM_PATH=/Users/craigsau/.rvm/gems/ruby-2.7.5:/Users/craigsau/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0:/opt/homebrew/Cellar/cocoapods/1.11.3/libexec' , execute `gem env` for more information from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1399:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1405:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1405:in `block in activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `each' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1387:in `activate_dependencies' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems/specification.rb:1369:in `activate' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:286:in `block in activate_bin_path' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:285:in `synchronize' from /opt/homebrew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/rubygems.rb:285:in `activate_bin_path' from /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `<main>'
已尝试操作
- 执行
gem install bundler - 执行
gem update --system
以上操作后重新运行pod install,问题依旧。
解决方向
- 直接安装rexml gem:先切换到报错中显示的Ruby版本(ruby-2.7.5),执行
rvm use 2.7.5,再运行gem install rexml,之后重新执行pod install。 - 修复Ruby环境冲突:报错中同时出现RVM管理的ruby-2.7.5和Homebrew安装的ruby-3.1.2,存在环境变量冲突。可执行
rvm alias create default ruby-2.7.5设置默认Ruby版本,重启终端后再尝试pod install。 - 为CocoaPods独立环境安装rexml:CocoaPods使用Homebrew安装时的独立gem环境(路径为
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec),可指定该路径安装:gem install rexml --install-dir /opt/homebrew/Cellar/cocoapods/1.11.3/libexec。 - 重新安装CocoaPods:卸载现有Homebrew版本的CocoaPods,执行
brew uninstall cocoapods;切换到ruby-2.7.5后,执行gem install cocoapods重新安装,再运行pod install。
内容的提问来源于stack exchange,提问作者CraigSau
相关产品推荐
相关产品推荐

