🛠️

psych (5.1.2) のインストールエラーを yaml-dev の追加で解決した話

に公開

An error occurred while installing psych (5.1.2), and Bundler cannot continue

Ruby 3.2 → 3.3 アップデート中でbundle installを行うとpsych (5.1.2) のインストールでエラーが発生しました。
原因と対処法をメモとしてまとめておきます。

エラー内容

 An error occurred while installing psych (5.1.2), and Bundler cannot continue.
 
 In Gemfile:
   debug was resolved to 1.10.0, which depends on
     irb was resolved to 1.14.3, which depends on
       rdoc was resolved to 6.10.0, which depends on
         psych

原因

psych は Ruby の YAML パーサーで、内部的に libyaml に依存しています。
このライブラリが環境に存在しないと、gem の native extension のビルドに失敗します。

解決方法

libyaml-dev(またはディストリビューションによっては yaml-dev)をインストールすることで解決できます。

参考:https://stackoverflow.com/questions/78438698/an-error-occurred-while-installing-psych-5-1-2-and-bundler-cannot-continue

Discussion