ruby 更新Cocoapods到1.13.0后,它抛出错误

wnvonmuf  于 11个月前  发布在  Ruby
关注(0)|答案(5)|浏览(193)

我更新了Cocoapods到1.13.0,在调用pod install后,它抛出了一个错误:
rb:108:in 'class:Array':ActiveSupport的未定义方法'deprecator':Module(NoMethodError)*

bundler: failed to load command: pod (/opt/homebrew/opt/bin/rbenv/versions/3.2.2/bin/pod)
/opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.0/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 /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
    from <internal:/opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb:9:in `<top (required)>'
    from <internal:/opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/bin/pod:36:in `<top (required)>'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/bin/pod:25:in `load'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/bin/pod:25:in `<top (required)>'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:45:in `block in <top (required)>'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:33:in `<top (required)>'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/bin/bundle:25:in `load'
    from /opt/homebrew/opt/bin/rbenv/versions/3.2.2/bin/bundle:25:in `<main>'

我该如何解决?

mutmk8jj

mutmk8jj1#

这种情况发生在Cocoapods安装中。
固定人,

sudo gem uninstall activesupport

这可能会要求您选择需要卸载的版本。选择版本。
然后安装工作版本

sudo gem install activesupport -v 7.0.8
ilmyapht

ilmyapht2#

看起来Cocoapods使用activesupport而没有指定确切的版本,并且最新版本(7.1.0)有一个bug。
找到了解决办法。限制为activesupport(7.0.8)的最后 * 稳定 * 版本。

gem 'activesupport', '~> 7.0', '<= 7.0.8'
o0lyfsai

o0lyfsai3#

将此行添加到项目文件夹的Gemfile中

gem 'activesupport', '~> 7.0.8'
  1. cd ios导航到ios文件夹。
  2. bundle install安装Bundler
  3. bundle update activesupport更新活动支持的版本
  4. bundle exec pod install安装CocoaPods管理的iOS依赖。
2guxujil

2guxujil4#

我的解决方案是在根目录的Gemfile中将原始的gem 'cocoapods'替换为下面的这个。

gem 'cocoapods', '~> 1.12'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'

然后,cd ios进入ios文件夹,并运行下面这些。它会像以前一样工作。我对这部分不熟悉。也许有些命令是不必要的。但对我很有效

1. bundle update
2. bundle install
3. pod repo update
4. bundle exec pod install
kognpnkq

kognpnkq5#

这是一个known bug,cocoapods团队已经将其升级为fixed,但尚未发布。
您可以通过添加1行代码轻松修复它,直到下一个版本:
1.用VSCode或其他东西打开/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb
1.在第7行添加require 'active_support',位于其他“require active_support/...”上方。

1.(sudo)保存文件并再次运行gem install cocoapods
这不是必需的,与此问题有关,但您也可以更新ruby和gem文件following this link以防止进一步的错误

相关问题