問題
$ rbenv install 3.1.0
が以下のように失敗した。
To follow progress, use 'tail -f /var/folders/71/yyv_lj_x3mxdb66f14803n140000gn/T/ruby-build.20230812151101.80080.log' or pass --verbose
Downloading openssl-3.1.1.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/b3aa61334233b852b63ddb048df181177c2c659eb9d4376008118f9c08d07674
Installing openssl-3.1.1...
Installed openssl-3.1.1 to /Users/daiki-kudo/.rbenv/versions/3.1.0
Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
BUILD FAILED (macOS 13.0.1 using ruby-build 20230717)
Inspect or clean up the working tree at /var/folders/71/yyv_lj_x3mxdb66f14803n140000gn/T/ruby-build.20230812151101.80080.bcwIBi
Results logged to /var/folders/71/yyv_lj_x3mxdb66f14803n140000gn/T/ruby-build.20230812151101.80080.log
Last 10 log lines:
static const struct kwtable *reserved_word(/*const char *, unsigned int*/);
^
defs/keywords:162:1: note: conflicting prototype is here
rb_reserved_word (register const char *str, register size_t len)
^
defs/keywords:6:36: note: expanded from macro 'rb_reserved_word'
#define rb_reserved_word(str, len) reserved_word(str, len)
^
2 warnings generated.
4 warnings generated.
No gem directory for 3.1.0
/var/folders/71/yyv_lj_x3mxdb66f14803n140000gn/T/ruby-build.20230812151101.80080.bcwIBi
を見に行くと、、、
compiling yjit.c
In file included from yjit.c:158:
./yjit_iface.c:17:10: fatal error: 'capstone/capstone.h' file not found
#include <capstone/capstone.h>
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [yjit.o] Error 1
解決策
LDFLAGSとCPPFLAGSを設定した上で、インストールすると成功した。ref
# $ export LDFLAGS="-L/usr/local/Cellar/capstone/4.0.2/lib"
# $ export CPPFLAGS="-I/usr/local/Cellar/capstone/4.0.2/include"
# 2023/09/17更新
$ export LDFLAGS="-L/usr/local/Cellar/capstone/5.0.1/lib"
$ export CPPFLAGS="-I/usr/local/Cellar/capstone/5.0.1/include"
$ rbenv install 3.1.0
To follow progress, use 'tail -f /var/folders/71/yyv_lj_x3mxdb66f14803n140000gn/T/ruby-build.20230812155304.88641.log' or pass --verbose
Downloading openssl-3.1.1.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/b3aa61334233b852b63ddb048df181177c2c659eb9d4376008118f9c08d07674
Installing openssl-3.1.1...
Installed openssl-3.1.1 to /Users/daiki-kudo/.rbenv/versions/3.1.0
Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
Installed ruby-3.1.0 to /Users/daiki-kudo/.rbenv/versions/3.1.0
Communized gems for 3.1.0
Ref.