Madogiwa Blog

主に技術系の学習メモに使っていきます。

Mac OS: rbenvでRuby 3.2.0をinstallが失敗したので対応方法をメモ📝

昨年末Ruby 3.2.0がリリースされましたね🎅🎄✨

www.ruby-lang.org

今更ながらローカルのRubyのバージョンをrbenvで3.2.0に上げようと思ったのですがエラーが発生したのでその対応方法とかをメモ📝

発生した問題

いつもどおり以下のコマンドでRuby 3.2.0をisntallしようとしたのですが、以下の通りエラーが発生し失敗しました😵

$ brew update && brew upgrade ruby-build
$ rbenv install 3.2.0

ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.6.3 using ruby-build 20230124)

Inspect or clean up the working tree at /var/folders/59/r452z9h94xn9py1wt_ffj8qh0000gn/T/ruby-build.20230128163250.53460.gt7TJp
Results logged to /var/folders/59/r452z9h94xn9py1wt_ffj8qh0000gn/T/ruby-build.20230128163250.53460.log

Last 10 log lines:
        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/59/r452z9h94xn9py1wt_ffj8qh0000gn/T/ruby-build.20230128163250.53460.gt7TJp/ruby-3.2.0/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

解決方法

以下のrbenv/ruby-buildのDiscussion記載の通り、

github.com

libyamlをinstallしてからRuby 3.2.0をinstallすることで解決しました🎉

$ brew install libyaml
$ rbenv install 3.2.0
$ rbenv global 3.2.0
$ ruby -v
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]