Apple Silicon MacにReviewの環境を構築した時に発生したエラーの対処方法

Today I Learned

Apple Silicon MacでReviewの環境を構築した際に、いくつかエラーが発生したので、その対処方法をメモする。

確認した環境

  • Apple Silicon Mac(M3)
  • macOS 14.3
  • Re:View 5.9.0

Rubyのインストールに失敗した

Apple Silicon MacにRuby 3.3.3をインストールしようとしたが、インストールに失敗した。
Rubyはmiseでインストールしている。

mise install ruby@3.3.3を実行したときのエラーメッセージ
mise plugins install ruby https://github.com/asdf-vm/asdf-ruby.git
mise install ruby@3.3.3

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  16.4M      0  0:00:01  0:00:01 --:--:-- 16.4M
mise ruby@3.3.3 -> ./configure "--prefix=$HOME/.local/share/mise/installs/ruby/3.3.3" --with-openssl-dir=/o 23s
...省略...
*** Following extensions are not compiled:
psych:
  Could not be configured. It will not be installed.
  Check /var/folders/x0/.../T/ruby-build.20240625194231.62742.twvBiy/ruby-3.3.3/ext/psych/mkmf.log for more details.

BUILD FAILED (macOS 14.3 on arm64 using ruby-build 20240612)

You can inspect the build directory at /var/folders/x0/.../T/ruby-build.20240625194231.62742.twvBiy
See the full build log at /var/folders/x0/.../T/ruby-build.20240625194231.62742.log
mise ~/.local/share/mise/plugins/ruby/bin/install exited with non-zero status: exit code 1
mise Run with --verbose or MISE_VERBOSE=1 for more information

原因と対処方法

エラーメッセージを見ると、psychのコンパイルに失敗していた。

*** Following extensions are not compiled:
psych:
  Could not be configured. It will not be installed.

「arm64 psych」で検索すると、libyamlをインストールする必要があるという情報が見つかったので、libyamlをインストールする。
参考記事:M1 Macでpsychがインストールできない問題と解消法

brew install libyaml

以上

補足 

Ruby 3.2からlibyamlが同梱されなくなったことが、今回の事象に影響していた。
Ruby 3.2.0 リリース

rake pdfコマンドの実行に失敗した

エラーメッセージ

rake pdfを実行したときのエラーメッセージ
rake pdf

review-pdfmaker  config.yml
 INFO    compiling preface.tex
 INFO    uplatex -interaction=nonstopmode -file-line-error -halt-on-error __REVIEW_BOOK__.tex
/Users/chick-p/.local/share/mise/installs/ruby/3.3.3/lib/ruby/3.3.0/open3.rb:534:in `spawn': No such file or directory - uplatex (Errno::ENOENT)
  from /Users/chick-p/.local/share/mise/installs/ruby/3.3.3/lib/ruby/3.3.0/open3.rb:534:in `popen_run'
  ...省略...
  from /Users/chick-p/.local/share/mise/installs/ruby/3.3.3/bin/review-pdfmaker:25:in `<main>'
rake aborted!
Command failed with status (1): [review-pdfmaker  config.yml]
lib/tasks/review.rake:112:in `block in <top (required)>'
Tasks: TOP => pdf => ReVIEW-Template.pdf
(See full trace by running task with --trace)

対処方法

エラーメッセージを見ると、uplatexが見つからないというエラーが出力されていた。

`spawn': No such file or directory - uplatex (Errno::ENOENT)

まずは、Homebrewでuplatexをインストールする。

brew install --cask mactex-no-gui

🍺  mactex-no-gui was successfully installed!
==> Caveats
==> mactex-no-gui
You must restart your terminal window for the installation of MacTeX CLI
tools to take effect.

Alternatively, Bash and Zsh users can run the command:

  eval "$(/usr/libexec/path_helper)"

インストールすると、以下のメッセージが表示されるのでzshの設定ファイルに以下を記載する。

~/.zshrc
eval "$(/usr/libexec/path_helper)"

zshの設定ファイルを再読み込みする。

source ~/.zshrc

以上