I tried creating a new project in 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
When creating the project I get this:
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.
Can you give me a hand?
3
Answers
I’m also experiencing this, under an older version of Ruby. I think it’s related to this recent commit to the
react-native
repo:https://github.com/facebook/react-native/commit/ce39931bc2b02f13cbc5751ba4d4a6dbc07bc91a
I think I’ve got a workaround while this is addressed (unless there’s some new prerequisite that’s not documented, I’m not au fait with the Ruby ecosystem)
The command that’s failing, after checking the
@react-native-community/cli
package, isbundle exec pod install
.If you re-run the init project command, let it fail, then
cd YourProjectName/ios/ && pod install
, it should work for you as if the official installer completed successfully.From there you can
yarn start
and run the application on iOS, Android etc.I fixed it based on this PR adding the following line to my Gemfile
Then rerunning
pod install
.The suggestion from Mike S. solved the issue for me, with one small change. I had to run
bundle install exec pod install
before subsequentpod install
commands would work.