我尝试在react native中创建一个新项目:
npx react-native@latest init myApp
> gem which cocoapods
/Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb
在创建项目时,我得到了这个:
Installing CocoaPods dependencies (this may take a few minutes)
error bundler: failed to load command: pod (/Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/bin/pod)
/Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/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 /Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/gems/activesupport-7.1.0/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
from <internal:/Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
from <internal:/Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
from /Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb:9:in `<top (required)>'
from <internal:/Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
from <internal:/Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
from /Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.13.0/bin/pod:36:in `<top (required)>'
from /Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/bin/pod:25:in `load'
from /Users/nameUser/Desktop/proj/myApp/vendor/bundle/ruby/3.2.0/bin/pod:25:in `<top (required)>'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492:in `exec'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28:in `start'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.20/exe/bundle:37:in `block in <top (required)>'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /Users/nameUser/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.20/exe/bundle:29:in `<top (required)>'
from /Users/nameUser/.rbenv/versions/3.2.2/bin/bundle:25:in `load'
from /Users/nameUser/.rbenv/versions/3.2.2/bin/bundle:25:in `<main>'
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/environment-setup?os=macos&platform=android and follow the React Native CLI QuickStart guide for macOS and iOS.
你能给予我一只手吗?
4条答案
按热度按时间bxpogfeg1#
我也经历过这个,在一个旧版本的Ruby下。我认为这与最近对
react-native
repo的提交有关:https://github.com/facebook/react-native/commit/ce39931bc2b02f13cbc5751ba4d4a6dbc07bc91a
我想我已经找到了一个解决方法(除非有一些新的先决条件没有文档记录,否则我不Au Ruby生态系统)
在检查
@react-native-community/cli
包后,失败的命令是bundle exec pod install
。如果你重新运行init project命令,让它失败,然后
cd YourProjectName/ios/ && pod install
,它应该为你工作,就像官方安装程序成功完成一样。从那里你可以
yarn start
和iOS上运行的应用程序,Android等.dauxcl2d2#
我在这个PR的基础上修复了它,并将下面一行添加到我的Gemfile中
然后重新运行
pod install
。ogsagwnx3#
这似乎是
activesupport
新版本中的一个bug。您可以降级,直到找到正确的版本。您可能需要更新您的Podfile格式以匹配不同的版本。举例来说:
ycggw6v24#
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
Mike S.解决了我的问题,一个小的变化。我必须先运行
bundle install exec pod install
,随后的pod install
命令才能工作。