LoginSignup
0
0

BUILD FAILED (macOS 13.5 on arm64 using ruby-build 20231114)

Last updated at Posted at 2023-11-27

事象

  • M2 Macで rbenv install 3.2.2 が通らない

解決策

  • .bashrcにhomebrewのpathを明示する
export PATH="/opt/homebrew/bin:$PATH"
  • .bashrcでRUBY_CONFIGURE_OPTSを指定する
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

原因と流れ

原因1(homebrewのpath)

.bashrcの記載を変えた際に、homebrewのpathを消去してしまっていた

$ rbenv install 3.2.2
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.2.2.tar.gz...
-> curl -q -fL -o ruby-3.2.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0  9946k      0  0:00:02  0:00:02 --:--:-- 9963k
==> Installing ruby-3.2.2...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.2.2" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-readline-dir=/usr/local/opt/readline --with-libyaml-dir=/usr/local/opt/libyaml
-> make -j 10

BUILD FAILED (macOS 13.5 on arm64 using ruby-build 20231114)
(省略)

詳細ログ

(省略)
ld: warning: search path '/opt/homebrew/opt/libffi/lib' not found
ld: warning: search path '/opt/homebrew/opt/libffi/lib' not found
(省略)

homebrewでインストールしたライブラリが見つからないことがわかる。

解決策

export PATH="/opt/homebrew/bin:$PATH"

原因2(RUBY_CONFIGURE_OPTSの指定)

$ rbenv install 3.2.2
==> Downloading ruby-3.2.2.tar.gz...
-> curl -q -fL -o ruby-3.2.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0   9.9M      0  0:00:01  0:00:01 --:--:-- 10.0M
==> Installing ruby-3.2.2...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.2.2" --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-openssl-dir=/opt/homebrew/opt/openssl@1.1
-> make -j 10
-> make install
-> "$HOME/.rbenv/versions/3.2.2/bin/ruby" -e <SCRIPT>
Loading the Ruby openssl extension failed (cannot load such file -- openssl)
See the extension log at (省略)
ERROR: Ruby install aborted due to missing extensions

BUILD FAILED (macOS 13.5 on arm64 using ruby-build 20231114)

解決策

Loading the Ruby openssl extension failedで検索してみると、下記の記事を見つけました。(ありがとうございます!!)

記事に記載されていた下記のコマンドを実行で、無事ruby 3.2.2のインストールに成功

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0