M1Mac rbenvでインストール失敗した時

投稿者:

内容

rbenvでいろんなバージョンインストールしようとしてもエラる

output:

$ rbenv install 3.0.3
Downloading openssl-1.1.1l.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/user/.rbenv/versions/3.0.3

Downloading ruby-3.0.3.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.3.tar.gz
Installing ruby-3.0.3...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.6.1 using ruby-build 20211203)

Inspect or clean up the working tree at /var/folders/5m/ctvxlp6x36d1y0vpb_y852mh0000gn/T/ruby-build.20211204145226.39915.c9xqmu
Results logged to /var/folders/5m/ctvxlp6x36d1y0vpb_y852mh0000gn/T/ruby-build.20211204145226.39915.log

Last 10 log lines:
make[1]: *** [ext/fiddle/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling wait.c
installing default console libraries
linking shared-object io/nonblock.bundle
linking shared-object io/wait.bundle
linking shared-object io/console.bundle
linking shared-object bigdecimal.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

エラーログはこなかじ

closure.c:279:14: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

2.7.5をインストールしようとしたときはこんなエラーログだった

readline.c:1904:37: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?

解決方法

どちらのバージョンもこれでインストールできた

 RUBY_CFLAGS="-Wno-error=implicit-function-declaration" arch -x86_64 rbenv install 3.0.2