问题
CocoaPods执行更新指令
pod --version
的时候遇到如下错误
/usr/local/lib/ruby/gems/3.2.0/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:108:in `<class:Array>': undefined method `deprecator' for ActiveSupport:Module (NoMethodError)
deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
^^^^^^^^^^^
Did you mean? deprecate_constant
from /usr/local/lib/ruby/gems/3.2.0/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from /usr/local/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb:9:in `<top (required)>'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
from /usr/local/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/bin/pod:36:in `<top (required)>'
from /usr/local/bin/pod:25:in `load'
from /usr/local/bin/pod:25:in `<main>'
解决
从错误上看Cocoapods 使用activesupport 中方法找不到对应的方法。
解决方案要先下载个老版本的activesupport,替换掉7.1.1。
1、下载旧版本activesupport
sudo gem install activesupport -v 7.0.8
2、查看是否下载完成
gem list
执行结果
*** LOCAL GEMS ***
abbrev (default: 0.1.1)
activesupport (7.1.1, 7.0.8)
addressable (2.8.5)
algoliasearch (1.27.5)
atomos (0.1.3)
base64 (default: 0.1.1)
benchmark (default: 0.2.1)
bigdecimal (default: 3.1.3)
bundler (default: 2.4.10)
CFPropertyList (3.0.6)
cgi (default: 0.3.6)
chunky_png (1.4.0)
claide (1.1.0)
cocoapods (1.13.0)
cocoapods-core (1.13.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
cocoapods-try (1.2.0)
colored2 (3.1.2)
compass (1.0.3)
compass-core (1.0.3)
compass-import-once (1.0.5)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
csv (default: 3.2.6)
date (default: 3.3.3)
debug (1.7.1)
delegate (default: 0.3.0)
did_you_mean (default: 1.6.3)
digest (default: 3.1.1)
drb (default: 2.1.1)
english (default: 0.7.2)
erb (default: 4.0.2)
error_highlight (default: 0.5.1)
escape (0.0.4)
etc (default: 1.4.2)
ethon (0.16.0)
fcntl (default: 1.0.2)
ffi (1.16.3, 1.15.5)
fiddle (default: 1.1.1)
fileutils (default: 1.7.0)
find (default: 0.1.1)
forwardable (default: 1.3.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
getoptlong (default: 0.2.0)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
io-console (default: 0.6.0)
io-nonblock (default: 0.2.0)
io-wait (default: 0.3.0)
ipaddr (default: 1.2.5)
irb (default: 1.6.2)
json (default: 2.6.3)
logger (default: 1.5.3)
matrix (0.4.2)
minitest (5.16.3)
molinillo (0.8.0)
multi_json (1.15.0)
mutex_m (default: 0.1.2)
nanaimo (0.3.0)
nap (1.1.0)
net-ftp (0.2.0)
net-http (default: 0.3.2)
net-imap (0.3.4)
net-pop (0.1.2)
net-protocol (default: 0.2.1)
net-smtp (0.3.3)
netrc (0.11.0)
nkf (default: 0.1.2)
observer (default: 0.1.1)
open-uri (default: 0.3.0)
open3 (default: 0.1.2)
openssl (default: 3.1.0)
optparse (default: 0.3.1)
ostruct (default: 0.5.5)
pathname (default: 0.2.1)
power_assert (2.0.3)
pp (default: 0.4.0)
prettyprint (default: 0.1.1)
prime (0.1.2)
pstore (default: 0.1.2)
psych (default: 5.0.1)
public_suffix (4.0.7)
racc (default: 1.6.2)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
rbs (2.8.2)
rdoc (default: 6.5.0)
readline (default: 0.0.3)
readline-ext (default: 0.1.5)
reline (default: 0.3.2)
resolv (default: 0.2.2)
resolv-replace (default: 0.1.1)
rexml (3.2.5)
rinda (default: 0.1.1)
rss (0.2.9)
ruby-macho (2.5.1)
ruby2_keywords (default: 0.0.5)
rubygems-update (3.4.21)
sass (3.4.25)
securerandom (default: 0.2.2)
set (default: 1.0.3)
shellwords (default: 0.1.0)
singleton (default: 0.1.1)
stringio (default: 3.0.4)
strscan (default: 3.0.5)
syntax_suggest (default: 1.0.2)
syslog (default: 0.1.1)
tempfile (default: 0.1.3)
test-unit (3.5.7)
time (default: 0.2.2)
timeout (default: 0.3.1)
tmpdir (default: 0.1.3)
tsort (default: 0.1.1)
typeprof (0.21.3)
typhoeus (1.4.0)
tzinfo (2.0.6)
un (default: 0.2.1)
uri (default: 0.12.1)
weakref (default: 0.1.2)
xcodeproj (1.23.0)
yaml (default: 0.2.1)
zlib (default: 3.0.0)
看到结果
activesupport (7.1.1, 7.0.8)
3、版本替换
sudo gem uninstall activesupport
执行结果
Select gem to uninstall:
1. activesupport-7.0.8
2. activesupport-7.1.1
3. All versions
>
这里输入 2 点击回车即可。
执行结果
Successfully uninstalled activesupport-7.1.1
4、查看版本是否替换完成
gem list
执行结果
activesupport (7.0.8)