青いやつの進捗日記。

メモとしてべんきょうのしんちょくをかいていきます。あとで自分が検索しやすいもん

asdfでruby入れようとしたらpsychのところでエラーになったのでlibyamlを自分で入れて解決

> asdf install ruby 3.2.9
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.2.9.tar.gz...
-> curl -q -fL -o ruby-3.2.9.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.9.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:  0 19.6M    0 28786    0     0    98k      0  0:03: 31 19.6M   31 6265k    0     0  4861k      0  0:00: 68 19.6M   68 13.3M    0     0  6008k      0  0:00:100 19.6M  100 19.6M    0     0  6658k      0  0:00:03  0:00:03 --:--:-- 6661k
==> Installing ruby-3.2.9...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.2.9" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-readline-dir=/usr/local/opt/readline --with-gmp-dir=/usr/local/opt/gmp --with-ext=openssl,psych,+
-> make -j 12
*** Following extensions are not compiled:
psych:
        Could not be configured. It will not be installed.
        Check /var/folders/z6/jh9v9bgd783fsn6c_2bx6hkr0000gn/T/ruby-build.20251115191223.55351.sUCzUb/ruby-3.2.9/ext/psych/mkmf.log for more details.

BUILD FAILED (macOS 15.3.2 on x86_64 using ruby-build 20251023)

You can inspect the build directory at /var/folders/z6/jh9v9bgd783fsn6c_2bx6hkr0000gn/T/ruby-build.20251115191223.55351.sUCzUb
See the full build log at /var/folders/z6/jh9v9bgd783fsn6c_2bx6hkr0000gn/T/ruby-build.20251115191223.55351.log
error installing version: failed to run install callback: exit status 1

psych 拡張が libyaml を見つけられず configure に失敗しているとのこと。
Codex CLIに聞きつつ解決方法を探ったところ、ruby-build は Homebrew 版を自動では拾えないことがあるらしく、まず brew install libyaml でライブラリを用意して、

> brew install libyaml

そのうえで asdf から Ruby を入れ直す前に、RUBY_CONFIGURE_OPTS で libyaml の場所を明示するために以下を.zsrhcに追記

export RUBY_CONFIGURE_OPTS="--with-libyaml-dir=$(brew --prefix libyaml)"

して source ~/.zshrc して読み込ませて再度インストールさせたらいけた。

> asdf install ruby 3.2.9
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.2.9.tar.gz...
-> curl -q -fL -o ruby-3.2.9.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.9.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:  2 19.6M    2  544k    0     0   720k      0  0:00: 23 19.6M   23 4740k    0     0  2708k      0  0:00: 45 19.6M   45 9170k    0     0  3321k      0  0:00: 59 19.6M   59 11.7M    0     0  3198k      0  0:00: 84 19.6M   84 16.5M    0     0  3563k      0  0:00: 99 19.6M   99 19.4M    0     0  3461k      0  0:00:100 19.6M  100 19.6M    0     0  3452k      0  0:00:05  0:00:05 --:--:-- 3773k
==> Installing ruby-3.2.9...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.2.9" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-readline-dir=/usr/local/opt/readline --with-gmp-dir=/usr/local/opt/gmp --with-ext=openssl,psych,+ --with-libyaml-dir=/usr/local/opt/libyaml
-> make -j 12
-> make install
==> Installed ruby-3.2.9 to /Users/motoki_watanabe/.asdf/installs/ruby/3.2.9