【Herokuエラー】Detected sqlite3 gem which is not supported on Heroku:

はじめに

Rails アプリを Heroku にデプロイしようとしたら

remote:        An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     Detected sqlite3 gem which is not supported on Heroku:
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

sqlite3は使えないよと怒られました。

HerokuはSQLiteが使えない

なので、開発・テスト環境ではSQLite3、本番環境ではPostgresqlを使うようにGemfileを修正しました。

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg', '1.2.3'
end

あとは以下のコマンドをたたいて、gemをインストールすればOKです。

$ bundle install

参考 f:id:haru89:20200620193932j:plain:w70

https://qiita.com/MosamosaPoodle/items/7149aa66f1c087472777