Ruby 2.2のインストールには Command Line Tools for Xcode 11が必要なようですが、Montereyでは少なくともバージョンが新しすぎてCommand Line Tools for Xcode 11をインストールできませんでした。
他には、エラーを無視するフラグを立てる方法があるようです。
macos - Problem when installing Ruby 2.2.9 on Mac Big Sur M1 - Stack Overflow
まずは以下でrbenv install 2.2.10
を試してみる:
export optflags="-Wno-error=implicit-function-declaration"
できた
$ rbenv install 2.2.10 Downloading openssl-1.0.2u.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16 Installing openssl-1.0.2u... Installed openssl-1.0.2u to /Users/kimura/.rbenv/versions/2.2.10 Downloading ruby-2.2.10.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.10.tar.bz2 Installing ruby-2.2.10... WARNING: ruby-2.2.10 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates. ruby-build: using readline from homebrew Installed ruby-2.2.10 to /Users/kimura/.rbenv/versions/2.2.10
できなかったら試してみようと思っていた設定:
CFLAGS="-Wno-error=implicit-function-declaration"