Ruby バージョンを 2.6.10 から 3.0.0 に更新中にエラーが発生しました
概要
RVM を使用して Ruby のバージョンを更新しようとすると問題が発生します。 RVM 自体の更新、最新の安定した Ruby バージョンのインストール、デフォルトとしての設定など、推奨される手順に従いました。しかし、これらの努力にもかかわらず、私の環境では Ruby のバージョンが正常に更新されないようです。 Ruby –version などのコマンドを実行すると、依然として古いバージョンが表示されます。また、RVM をクリーンアップし、シェルを再起動し、PATH を再確認してみましたが、問題は解決しません。 RVM を使用して Ruby バージョンをトラブルシューティングし、正常に更新する方法に関するガイダンスや洞察をいただければ幸いです。
たとえば、rvm install 3.0.0を実行すると、それが得られます
Error running '__rvm_make -j8', please read /Users/apple/.rvm/log/1703760048_ruby-3.0.0/make.log
There has been an error while running make. Halting the installation.```
そして、メイクログを確認すると、次のような結果が得られます。
../.././include/ruby/ruby.h:1837:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
ancdata.c:1440:36: note: ')' token is here
ary = rb_attr_get(ctl, rb_intern("unix_rights"));
^~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1847:56: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....`your text`
linking shared-object json/ext/parser.bundle
raddrinfo.c:2687:18: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
id_timeout = rb_intern("timeout");
^~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^
raddrinfo.c:2687:18: note: '{' token is here
id_timeout = rb_intern("timeout");
^~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1832:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
raddrinfo.c:2687:18: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
id_timeout = rb_intern("timeout");
^~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1837:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
raddrinfo.c:2687:18: note: ')' token is here
id_timeout = rb_intern("timeout");
^~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:1847:56: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^
18 warnings generated.
30 warnings generated.
2 warnings generated.
linking shared-object socket.bundle
12 warnings generated.
linking shared-object ripper.bundle
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
そしてrbenvで試してみるとこれが得られます
BUILD FAILED (macOS 13.6.1 on x86_64 using ruby-build 20231225)
更新プロセスの推奨手順に従いました。これには、rvm get stack を使用して RVM 自体を更新すること、rvm install Ruby –latest を使用して最新の安定した Ruby バージョンをインストールすること、および rvm use Ruby –default を使用して新しくインストールされたバージョンをデフォルトとして設定することが含まれます。
解決策
makefile にエラー make[1]: *** [ext/openssl/all] Error 2 があるため、これを検討して、適切な Openssl バイナリをリンクする必要があるとします。したがって、ターミナルで次のコマンドを発行します。
which openssl
次のような結果が得られた場合:
/usr/local/bin/openssl
次に、openssl バイナリがどこにあるかを make に伝える必要があります。 what コマンドから返されたパスを使用して、これを試してください。
rvm install ruby-3.0.0 --with-openssl-dir=/usr/local/bin/openssl
openssl パスを何でも置き換えてください。