elasticbeanstalk(rails2.0)のproduction環境をmysqlに変更し、デプロイ時にエラーがでたのでメモ
エラー内容
[Instance: i-0e01735f21d78e0a0] Command failed on instance. Return code: 1 Output: (TRUNCATED)...undle. Add it to Gemfile. /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `load' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `<main>' Tasks: TOP => environment (See full trace by running task with --trace). Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
対処
eb sshで接続して原因を調べる
eb ssh
eb-activity.logを見る
vi /var/log/eb-activity.log
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `load' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `<main>' Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile. /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `load' /opt/rubies/ruby-2.2.5/bin/bundle:23:in `<main>' Tasks: TOP => environment (See full trace by running task with --trace) (Executor::NonZeroExitStatus)
Gemが足りていないみたいなので記載する
Gemfileにgem 'mysql2'を追記しデプロイ
なおる!