rbenv: Big Sur から MacOS Sonoma 14 にアップグレードした後、ruby 2.1.0 をインストールできない

概要

Ruby 2.1.0 を使用するレガシー アプリケーションがあります。 $ rbenv インストール 2.1.0 ビッグサーではうまくいきました。

しかし、Big Sur 11 から MacOS 14.4.1 Sonoma にアップデートした後、動作させることができません。 古いrbenvバージョンをクリーンなgit installに置き換えて成功しました

$ rbenv -v
rbenv 1.2.0-87-ge8b7a27

Sonoma にアップグレードした後、XCode コマンド ツールをインストールしました。 私は MacPorts を使用しており、その指示に従ってすべてのポートを再インストールしました。

$ uname -a
Darwin xoco6p.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024; root:xnu-10063.101.17~1/RELEASE_X86_64 x86_64

$ rbenv install 2.1.0
==> Installing yaml-0.1.6...
-> ./configure "--prefix=$HOME/.rbenv/versions/2.1.0"
-> make -j 12
-> make install
==> Installed yaml-0.1.6 to /Users/jose/.rbenv/versions/2.1.0
==> Installing openssl-1.0.2u...
-> ./config "--prefix=$HOME/.rbenv/versions/2.1.0/openssl" "--openssldir=$HOME/.rbenv/versions/2.1.0/openssl/ssl" zlib-dynamic no-ssl3 shared no-ssl2 no-krb5
-> make -j 12

BUILD FAILED (macOS 14.4.1 on x86_64 using ruby-build 20240416)

You can inspect the build directory at /Users/jose/MyTemp/ruby-build.20240424214638.52529.gppzyT
See the full build log at /Users/jose/MyTemp/ruby-build.20240424214638.52529.log

ログ ファイルには、openssl make ファイルの構成に失敗したことが示されています。

$ less /Users/jose/MyTemp/ruby-build.20240424214638.52529.log
.........
 ==> Installed yaml-0.1.6 to /Users/jose/.rbenv/versions/2.1.0
cd /Users/jose/MyTemp/ruby-build.20240424214638.52529.gppzyT
-> tar xzf openssl-1.0.2u.tar.gz
cd /Users/jose/MyTemp/ruby-build.20240424214638.52529.gppzyT/openssl-1.0.2u
==> Installing openssl-1.0.2u...
-> ./config "--prefix=$HOME/.rbenv/versions/2.1.0/openssl" "--openssldir=$HOME/.rbenv/versions/2.1.0/openssl/ssl" zlib-dynamic no-ssl3 shared no-ssl2 no-krb5
Operating system: i686-apple-darwinDarwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024; root:xnu-10063.101.17~1/RELEASE_X86_64
WARNING! If you wish to build 64-bit library, then you have to
         invoke './Configure darwin64-x86_64-cc' *manually*.
Configuring for darwin-i386-cc
.........
  "_time", referenced from:
      _CRYPTO_dbg_malloc in libcrypto.a(mem_dbg.o)
      _bnrand in libcrypto.a(bn_rand.o)
      _RAND_poll in libcrypto.a(rand_unix.o)
      _ASN1_TIME_diff in libcrypto.a(a_time.o)
      _X509_cmp_time in libcrypto.a(x509_vfy.o)
      _X509_time_adj in libcrypto.a(x509_vfy.o)
      _X509_gmtime_adj in libcrypto.a(x509_vfy.o)
      ...
     (maybe you meant: _X509_cmp_time, _TS_TST_INFO_set_time , _X509_time_adj , _X509_STORE_CTX_set_time , _err_clear_last_constant_time , _TS_RESP_CTX_set_time_cb , _PKCS7_add0_attrib_signing_time , _X509_VERIFY_PARAM_set_time , _ASN1_UTCTIME_cmp_time_t , _X509_time_adj_ex , _TS_TST_INFO_get_time , _X509_cmp_current_time )
  "_vfprintf", referenced from:
      _OPENSSL_showfatal in libcrypto.a(cryptlib.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [link_a.darwin] Error 1
make[3]: *** [do_darwin-shared] Error 2
make[2]: *** [libcrypto.1.0.0.dylib] Error 2
make[1]: *** [shared] Error 2
make: *** [build_crypto] Error 1
external command failed with status 2

x86_64 用の構成に失敗しているようで、i386 で続行されます。

rbenv を使用して Ruby 2.1.0 をインストールする方法を教えていただけますか? 最高、 ホセ・アンブロス・インガーソン

解決策

これを突き止めるのはかなり面倒ですが、これは最新の OpenSSL バージョンの問題だと思います。rvm のさまざまなバージョンで経験したことと非常によく似ています。

RVM インストール 2.1.0 –with-openssl-dir=/usr/local/opt/openssl@3

追加の –with-openssl-dir=/usr/local/opt/openssl@3 を指定して rbenv インストールを試してください。

rbenv 固有のオプションの詳細