1. 環境
- MacBook Pro (13-inch, 2020)
- macOS Ventura 13.1
- Homebrew:3.6.20(※)
- xcode-select:2396(※)
※ エラー解決後のバージョン
2. 発生した問題
rbenvでRuby 3.1.1をインストールしようとしたら以下のエラーが発生。
$ rbenv install 3.1.1 Downloading openssl-3.0.5.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/aa7d8d9bef71ad6525c55ba11e5f4397889ce49c2c9349dcea6d3e4f0b024a7a Installing openssl-3.0.5... Installed openssl-3.0.5 to /Users/kazunoko/.rbenv/versions/3.1.1 Downloading ruby-3.1.1.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.1.tar.gz Installing ruby-3.1.1... ruby-build: using readline from homebrew BUILD FAILED (macOS 13.1 using ruby-build 20220726) Inspect or clean up the working tree at /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123081732.42760.Fk3kTB Results logged to /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123081732.42760.log Last 10 log lines: ^ In file included from compile.c:40: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. make: *** [compile.o] Error 1
出力された/var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123081732.42760.log
を確認(最後の方だけ抜粋)。
In file included from debug.c:27: ./vm_callinfo.h:175:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ In file included from debug.c:27: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. make: *** [debug.o] Error 1 make: *** Waiting for unfinished jobs.... In file included from compile.c:40: ./vm_callinfo.h:175:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ In file included from compile.c:40: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. make: *** [compile.o] Error 1
3. 解決方法
ruby-buildのwikiのSuggested build environmentに従って以下のコマンドを実行。
$ brew install openssl@3 readline libyaml gmp $ export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)"
10分以上かかって色々インストールが完了し、環境変数の設定も完了。
再度Ruby 3.1.1をインストールしてみるも、以下のエラーが発生。
$ rbenv install 3.1.1 To follow progress, use 'tail -f /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123093647.99361.log' or pass --verbose Downloading ruby-3.1.1.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.1.tar.gz Installing ruby-3.1.1... ruby-build: using readline from homebrew ruby-build: using gmp from homebrew BUILD FAILED (macOS 13.1 using ruby-build 20221225) Inspect or clean up the working tree at /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123093647.99361.VH2vnQ Results logged to /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123093647.99361.log Last 10 log lines: ^ In file included from compile.c:40: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. make: *** [compile.o] Error 1
出力された/var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123093647.99361.log
を確認(最後の方だけ抜粋)。
In file included from debug.c:27: ./vm_callinfo.h:175:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ In file included from debug.c:27: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. compiling dln_find.c make: *** [debug.o] Error 1 make: *** Waiting for unfinished jobs.... In file included from compile.c:40: ./vm_callinfo.h:175:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ In file included from compile.c:40: ./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING' if (debug) rp(ci); ^ ./internal.h:94:72: note: expanded from macro 'rp' #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING) ^ 2 errors generated. make: *** [compile.o] Error 1
ログにあるRUBY_FUNCTION_NAME_STRING
で調べてみて、ruby-buildのissuesのRuby installation fails in macOS Catalina #1409がヒット。
このコメントにある以下のコマンドを実行。
$ sudo rm -rf /Library/Developer/CommandLineTools $ sudo xcode-select --install
ダイアログの指示に従いCommand Line Tools for Xcodeをインストール。
再度Ruby 3.1.1をインストール。
$ rbenv install 3.1.1 To follow progress, use 'tail -f /var/folders/m9/r1bz5qns0nj2ysmyrqwpn3j00000gn/T/ruby-build.20230123104923.9665.log' or pass --verbose Downloading ruby-3.1.1.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.1.tar.gz Installing ruby-3.1.1... ruby-build: using readline from homebrew ruby-build: using gmp from homebrew Installed ruby-3.1.1 to /Users/kazunoko/.rbenv/versions/3.1.1
無事インストールできました!
【参考】
- rbenv install で BUILD FAILED - インゲージ開発者ブログ
- `require': cannot load such file -- openssl (LoadError) というエラーが出てRuby 2.7.6がインストールできない場合の対処法 - Qiita
- M1 Macbook Proにrbenv経由でRubyをインストールしようとしたらエラーになってハマった - 行動すれば次の現実
- macでRubyをビルドしたときにRUBY_FUNCTION_NAME_STRINGのerrorが出た場合 | Blog
- brew upgrade でのエラー対処からCommand Line Toolsについてまとめてみる|TechRacho by BPS株式会社
- MacのhomebrewでOpenSSLがビルドエラーになる場合の対処方法|TechRacho by BPS株式会社