Apple M1 Mac では RVM インストール 2.6.7 が常に失敗する
概要
RVM 2.6.7 のインストール中に M1 Mac で常に次のエラーが発生します
me@xx ~ % rvm install 2.6.7
ruby-2.6.7 - #removing src/ruby-2.6.7 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/11.5/x86_64/ruby-2.6.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/me/.rvm/rubies/ruby-2.6.7, this may take a while depending on your cpu(s)...
ruby-2.6.7 - #downloading ruby-2.6.7, this may take a while depending on your connection...
ruby-2.6.7 - #extracting ruby-2.6.7 to /Users/me/.rvm/src/ruby-2.6.7 - please wait
ruby-2.6.7 - #configuring - please wait
ruby-2.6.7 - #post-configuration - please wait
ruby-2.6.7 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/me/.rvm/log/1629787822_ruby-2.6.7/make.log
There has been an error while running make. Halting the installation.
解決策
はい、これはアップストリームの既知の問題です: https://bugs.ruby-lang.org/issues/17777 Ruby-build もこの問題を追跡しています: https://github.com/rbenv/ruby-build/issues/1489
回避策は、次のコードを実行し、Ruby 2.6.7 を再度インストールすることです。
$ export warnflags=-Wno-error=implicit-function-declaration
$ rbenv install 2.6.7
-または-
$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.7
これは、ネイティブ拡張機能を使用した gem のインストールにも影響を与える可能性があるようです (mysql2 もその 1 つです)。
gem install <GEMNAME> -- --with-cflags="-Wno-error=implicit-function-declaration"
参考: Mac OS に Ruby 2.6.7 をインストールする際のエラー - 解決方法?