It looks like you have two versions of Ruby installed. (3.3.0 and 2.6.10.210)
How to solve the problem?
peter@mac ios % sudo gem update --system
Password:
Updating rubygems-update
Fetching rubygems-update-3.5.6.gem
ERROR: Error installing rubygems-update:
There are no versions of rubygems-update (= 3.5.6) compatible with your Ruby & RubyGems
rubygems-update requires Ruby version >= 3.0.0. The current ruby version is 2.6.10.210.
ERROR: While executing gem ... (NoMethodError)
undefined method `version' for nil:NilClass
peter@mac ios % brew install ruby
==> Downloading https://formulae.brew.sh/api/formula.jws.json
################################################################################################################################################################################################################################# 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
################################################################################################################################################################################################################################# 100.0%
Warning: ruby 3.3.0 is already installed and up-to-date.
To reinstall 3.3.0, run:
brew reinstall ruby
peter@mac ios % brew install rubygems-update
Warning: No available formula with the name "rubygems-update".
==> Searching for similarly named formulae and casks...
Error: No formulae or casks found for rubygems-update.
peter@mac ios % brew install rubygems
Warning: No available formula with the name "rubygems". Did you mean rubyfmt?
macOS provides gem as part of Ruby. To install a newer version:
brew install ruby
peter@mac ios % brew upgrade ruby
Warning: ruby 3.3.0 already installed
peter@mac ios %