Techioz Blog

AWS Elastic Beanstalk にアプリをデプロイする際の Ruby バージョン エラー

概要

Ruby on Rails アプリケーションを AWS Elastic Beanstalk にデプロイしようとしています。次のエラーが発生します -

ERROR: [Instance: <Instance ID>] Command failed on instance. Return code: 18 Output: (TRUNCATED)...e ']'
+ bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Your Ruby version is 2.4.3, but your Gemfile specified 2.3.3.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) '<Instance ID>'. Aborting the operation.
ERROR: Failed to deploy application.

このエラーが発生した後、Gemfile から Ruby のバージョン番号を削除しましたが、それでもこのエラーが発生しました。

その後、Gemfile で Ruby のバージョンについて何も言及せずに、新しい Beanstalk 環境にアプリをデプロイしました。しかし、まだ同じエラーが発生します。

解決策

以前の回答は、Ruby の古くて安全でないバージョンの問題について尋ねた別の質問に対して同様の回答をしたため削除されましたが、2.4.3 などの安全でないバージョンの Ruby を使用してエラーに遭遇した人に与えるのと同じアドバイスを繰り返します。 : 3 以降、または少なくとも 2.7 および対応する互換性のある Bundler バージョンに更新します。

管理者への注意: この回答が削除に値する場合は、この質問も削除し、サポートされている Ruby バージョンで再投稿するようユーザーに依頼してください。