Due to Homebew of Rosetta version, I struggled with installing ruby 3.2.2 by rbenv.
Here is the error.
*** Following extensions are not compiled: psych: Could not be configured. It will not be installed. Check ext/psych/mkmf.log for more details. *** Fix the problems, then remove these directories and try again if you want. Generating RDoc documentation /private/var/folders/_0/n4zrvrn14y15r7g522ypt8tm0000gn/T/ruby-build.20230516235445.90248.zsr1nZ/ruby-3.2.2/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. uh-oh! RDoc had a problem: cannot load such file -- psych run with --debug for full backtrace make: *** [rdoc] Error 1
I tried these and it worked for me:
Uninstall Rosetta version of Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
Reinstall Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install libyaml
brew install libyaml
Specify libyaml's path by RUBY_CONFIGURE_OPTS arg on Ruby installation
RUBY_CONFIGURE_OPTS=--with-libyaml-dir="$(brew --prefix libyaml)" rbenv --debug install 3.2.2