LoginSignup
1
1

More than 5 years have passed since last update.

Capistrano3でRailsアプリをデプロイしようとしたら'mysql2 is not part of the bundle. add it to your gemfile.'が出た

Last updated at Posted at 2019-03-20

概要

Capistrano3を使ってRailsアプリをさくらvpsにデプロイしようとしたところエラーが出てはまったので、解決方法をメモとして書いておきます。

Capistrano3を使ったデプロイの手順は以下を参考にさせて頂きました。
(初心者向け)vpsを契約して、capistrano3でRailsアプリをデプロイするまで [その1 サーバー設定編]
(初心者向け)vpsを契約して、Capistrano3でRailsアプリをデプロイするまで [その2 ローカル設定編]

エラー内容

上記のサイトを参考に以下のコマンドを実行してデプロイしようとしたところ、下記のエラーが出てデプロイに失敗しました。

$ bundle exec cap production deploy
・・・
01 rake aborted!
01 LoadError: Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? mysql2 is not part of the bundle. Add it to your Gemfile.
・・・

解決方法

Gemfileのproductionグループにmysql2を追加しインストールします。

group :production, :staging do
  gem 'mysql2'
end
$ bundle install

ここでデプロイし直しても同じエラーが出てしまいますので、githubへ変更をpushします。

$ git add .
$ git commit -m 'Add mysql2 to Gemfile'
$ git push origin master

デプロイし直すと成功しました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1