今回は小ネタです。しかも、iOSの開発している人しか発生しないかもしれないです。
rbenvを使って別のバージョンのRubyをインストールしようと思ったら下記のエラーが発生しました。
$ rbenv install 3.1.2 Downloading openssl-3.0.5.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/aa7d8d9bef71ad6525c55ba11e5f4397889ce49c2c9349dcea6d3e4f0b024a7a Installing openssl-3.0.5... BUILD FAILED (macOS 12.6.4 using ruby-build 20220721) Inspect or clean up the working tree at /var/folders/14/zqq9_0gx5s5f78ks8s_p4k240000gn/T/ruby-build.20231209082717.65642.nfBnoE Results logged to /var/folders/14/zqq9_0gx5s5f78ks8s_p4k240000gn/T/ruby-build.20231209082717.65642.log Last 10 log lines: *** *** *** perl configdata.pm --dump *** *** *** *** (If you are new to OpenSSL, you might want to consult the *** *** 'Troubleshooting' section in the INSTALL.md file first) *** *** *** ********************************************************************** xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools. See `man xcode-select` for more details.
対応方法はログに記載のあるようにXCodeのxcrunコマンドに参照問題を解消すれば大丈夫でした。 自分がインストールしていたXCodeのパスを選択することでインストールできるようになりました。
sudo xcode-select --switch path/to/Xcode.app(Xcodeのパスを指定)
まとめ
Xcodeを入れていると結構ややこしいことが起こる可能性があるので注意が必要です。
Rubyの設定がバッティングしてエラーになることもありそうです。