Ale*_*tor 51 ruby rubygems ios cocoapods
我将 CocoaPods 更新到版本1.13.0. 现在,当我运行时pod install,它会抛出以下错误:
conversions.rb:108:in '<class:Array>': undefined method 'deprecator' for ActiveSupport:Module (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
我该如何修复它?
这是完整的错误:
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>'
Run Code Online (Sandbox Code Playgroud)
Dan*_*ath 78
安装 CocoaPods 版本时会发生这种情况1.13.0。该问题已在 CocoaPods 项目中报告此处)。
您可以通过将activesupport gem 降级到版本来解决该问题7.0.8。首先在终端中运行以下命令:
sudo gem uninstall activesupport
Run Code Online (Sandbox Code Playgroud)
这可能会要求您选择要卸载的版本。如果是,请选择版本。
然后通过在终端中运行以下命令来安装可用的版本:
sudo gem install activesupport -v 7.0.8
Run Code Online (Sandbox Code Playgroud)
Ale*_*tor 31
看起来 Cocoapods 使用时activesupport没有指定确切的版本,并且上一个版本(7.1.0)有一个错误。
找到解决方法。限制为 (7.0.8) 的最新稳定版本activesupport。
gem 'activesupport', '~> 7.0', '<= 7.0.8'
Run Code Online (Sandbox Code Playgroud)
小智 13
将此行添加到项目文件夹的 Gemfile 中
gem 'activesupport', '~> 7.0.8'
Run Code Online (Sandbox Code Playgroud)
cd ios导航到 ios 文件夹。bundle install安装捆绑器bundle update activesupport更新主动支持的版本bundle exec pod install安装 CocoaPods 管理的 iOS 依赖项。小智 8
gem 'cocoapods'我的解决方案是在根目录下的 Gemfile 中用下面的内容替换原来的。
gem 'cocoapods', '~> 1.12'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
Run Code Online (Sandbox Code Playgroud)
然后,cd ios进入 ios 文件夹并运行以下这些。它会像以前一样工作。我对这部分不熟悉。也许有些命令是不必要的。但这对我有用。
1. bundle update
2. bundle install
3. pod repo update
4. bundle exec pod install
Run Code Online (Sandbox Code Playgroud)
这是一个已知的错误,已被 cocoapods 团队修复,但尚未发布。
您可以通过添加 1 行代码轻松修复它,直到下一个版本:
/opt/homebrew/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb用VSCode什么的打开。
require 'active_support'在第 7 行添加其他“require active_support/...”。

gem install cocoapods再次运行。这不是必需的并且与此问题相关,但您也可以按照此链接更新您的 ruby 和 gem 文件以防止进一步的错误
| 归档时间: |
|
| 查看次数: |
20728 次 |
| 最近记录: |