CocoaPods installed but not working (need to upgrade ruby?)

Brand new Mac mini (I want to start dabbling in iOS app dev). Freshly updated to Sequoia 15.5 then installed Xcode 16.4. Then CocoaPods, flutter 3.32.0, visual studio code with the flutter extension, all following the install instructions. I got to the part to run ‘flutter doctor’ and I see:

[!] Xcode - develop for iOS and macOS (Xcode 16.4) [735ms]
Xcode at /Applications/Xcode.app/Contents/Developer
Build 16F6
CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
For re-installation instructions, see CocoaPods Guides - Getting Started

Did as instructed, but no luck, the problem persists. One thing I’ll note in retrospect is that during the CocoaPods install, I kept running into dependencies that wanted specific downgraded versions, which basically started with “your version of ruby is too old”. This problem seems to have started with Sequoia coming stock with an older version of ruby.:

ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin24]

I’m wondering if flutter, CocoaPods, etc, need a newer version of ruby. But I read elsewhere that updating ruby on Mac is not advised because it can break other things, which gave me pause. Does getting flutter and dependencies working require a particular minimum version of ruby so I should just go for it and try again?

Final detail that may be relevant:
gem which cocoapods
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.16.2/lib/cocoapods.rb
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.16.2/lib/cocoapods.rb

  1. Install Homebrew : https://brew.sh
  2. Install Ruby using Homebrew: brew install ruby
  3. Update your shell PATH :

For Intel Macs

echo ‘export PATH=“/usr/local/opt/ruby/bin:$PATH”’ >> ~/.zshrc

For Apple Silicon (M1/M2/M3) Macs

echo ‘export PATH=“/opt/homebrew/opt/ruby/bin:$PATH”’ >> ~/.zshrc

Apply the changes

source ~/.zshrc

  1. Verify the Ruby Version

Before installing, make sure you aren’t using the system version (which is usually 2.6.x and often causes permission errors). : which ruby
It should point to a path inside /opt/homebrew/... or /usr/local/... . If it says /usr/bin/ruby , the path update in Step 1 didn’t take effect yet; try restarting your terminal.

  1. Install CocoaPods

Now that you’re using the Homebrew Ruby, you can install CocoaPods as a “gem.” Crucially, do not use sudo here. One of the main benefits of using Homebrew Ruby is that you own the folder, so you don’t need root permissions. : gem install cocoapods