Ruby が新しいバージョンをインストールしない
概要
Ruby 2.7.6をインストールしようとしていますが、実行すると % rbenv バージョン
わかりました:
ファイル .ruby-version に次のものがあります: 2.7.6
実行時: %。 rbenv インストール エラーになります:
注記:
ターミナルトレース
> (base) uxdw@MacBook-Pro [FOLDER] % rbenv install
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...
patching file test/v3ext.c
Installed openssl-1.1.1q to /Users/[USER]/.rbenv/versions/2.7.6
Downloading ruby-2.7.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.5 using ruby-build 20220726)
Inspect or clean up the working tree at /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.lmy9oj
Results logged to /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.log
Last 10 log lines:
compiling date_parse.c
linking shared-object strscan.bundle
compiling date_strftime.c
compiling date_strptime.c
linking shared-object io/console.bundle
installing default date_core libraries
linking shared-object objspace.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
(base) uxdw@MacBook-Pro [FOLDER] %
解決策
rbenv は openssl-1.1.1q を前提条件としてインストールしていますが、ARM64 バージョンに少なくとも 1 つ存在する include ステートメントが欠落しているためにクラッシュします。これは M1 および M2 MBP の場合に当てはまります。そのため、上記の説明に基づいて推測します。
brew install [email protected]
export PATH="`brew --prefix [email protected]`/bin:$PATH"
export LDFLAGS="-L`brew --prefix [email protected]`/lib"
export CPPFLAGS="-I`brew --prefix [email protected]`/include"
export PKG_CONFIG_PATH="`brew --prefix [email protected]`/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix [email protected]`"
CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix [email protected]` rbenv install 2.7.6