概要
rbenv で新しく別バージョンの Ruby をインストールしたかったが、install
コマンドを叩いた際に以下のようなエラーが発生。
$ rbenv install 2.7.0
Downloading openssl-1.1.1d.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
Installing openssl-1.1.1d...
BUILD FAILED (OS X 10.15.4 using ruby-build 20200401)
Inspect or clean up the working tree at /var/folders/w_/0xyscdr105gdxd26fpl679f40000gn/T/ruby-build.20200503102702.1876.6wZCKR
Results logged to /var/folders/w_/0xyscdr105gdxd26fpl679f40000gn/T/ruby-build.20200503102702.1876.log
Last 10 log lines:
In file included from apps/app_rand.c:10:
In file included from apps/apps.h:13:
In file included from ./e_os.h:16:
In file included from include/openssl/e_os2.h:243:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/inttypes.h:16:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
^~~~~~~~~~~~
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
make: *** [all] Error 2
解決法
以下を .bashrc
や .zshrc
に書き、 export する。
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
試したもの
-
rbenv による Ruby のインストール失敗と解決
- CommandLineTools の再インストール
参考
macOS 10.15 Catalinaで、"fatal error: 'stdio.h' file not found"が出てしまう!
おまけ
そもそも、なぜ新しく Ruby をインストールしようとしたかというと、bundle install
がうまくいかず、試しに新しいバージョンの Ruby をインストールしたら治るかと思い、試すと起こりました。
尚、上記 bundle install
時にうまくいかないのも上記解決法でおそらく解決できたかと思います。
エラーメッセージまではちょっと取っていなかったのですが、ffi
という gem をインストールしようとした際に
以下のようなメッセージと共に表示されていました。
ERROR: Failed to build gem native extension.