お久しぶりです。
M1 Macにしてからたくさんエラー出てゲンナリしてるのですぐ見返せるようにメモしておきます。
エラー
ruby 3.0.2 を入れたとき
$ rbenv install 3.0.2
Downloading openssl-1.1.1l.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/***/.anyenv/envs/rbenv/versions/3.0.2
Downloading ruby-3.0.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
Installing ruby-3.0.2...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 11.6 using ruby-build 20210825)
Inspect or clean up the working tree at /var/folders/s3/qcrn2vp17j7bp1qss56cg4n80000gn/T/ruby-build.20211030161412.21719.D9EvS1
Results logged to /var/folders/s3/qcrn2vp17j7bp1qss56cg4n80000gn/T/ruby-build.20211030161412.21719.log
Last 10 log lines:
linking shared-object psych.bundle
compiling ossl_x509ext.c
compiling ossl_x509name.c
compiling ossl_x509req.c
compiling ossl_x509revoked.c
compiling ossl_x509store.c
installing default openssl libraries
linking shared-object openssl.bundle
linking shared-object ripper.bundle
make: *** [build-ext] Error 2
解決策
オプション付けたら行けます。
RUBY_CONFIGURE_OPTS=--with-readline-dir="$(abrew --prefix readline)" \rbenv install *.*.*
$ RUBY_CONFIGURE_OPTS=--with-readline-dir="$(abrew --prefix readline)" \rbenv install 3.0.2
zsh: command not found: abrew
Downloading openssl-1.1.1l.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/***/.anyenv/envs/rbenv/versions/3.0.2
Downloading ruby-3.0.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
Installing ruby-3.0.2...
Installed ruby-3.0.2 to /Users/***/.anyenv/envs/rbenv/versions/3.0.2