✅ 安装 ruby 2.4.1/2.3.3 均可以安装成功
安装指南
安装
rbenv install 2.4.1
==> Installing ruby-2.4.1...
WARNING: ruby-2.4.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/2.4.1" --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-openssl-dir=/opt/homebrew/opt/openssl@1.1
BUILD FAILED (macOS 14.6.1 on arm64 using ruby-build 20241105-9-g7ccb143c)
You can inspect the build directory at /var/folders/4_/0ykpgcrj60b6rthkzffk6gfw0000gn/T/ruby-build.20250117105744.95323.0WmFO7
See the full build log at /var/folders/4_/0ykpgcrj60b6rthkzffk6gfw0000gn/T/ruby-build.20250117105744.95323.log
# 查看log 关键信息如下
checking whether it is safe to define __EXTENSIONS__... yes
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... yes
checking whether LDFLAGS is valid... no
configure: error: something wrong with LDFLAGS="-L/usr/local/opt/mysql-client/lib"
external command failed with status 1
如下方式
# 添加以下环境变量
brew install libffi
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)"
# 再次安装
rbenv install 2.4.1
安装过程,细节如下
$ p rbenv install 2.4.1
==> Installing ruby-2.4.1...
WARNING: ruby-2.4.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/2.4.1" --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-openssl-dir=/opt/homebrew/opt/openssl@1.0
-> make -j 8
-> make install
==> Installed ruby-2.4.1 to /Users/ap7/.rbenv/versions/2.4.1
rbenv: cannot rehash: /Users/ap7/.rbenv/shims/.rbenv-shim exists