36
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HerokuではSQLite3が使えない?!

Last updated at Posted at 2017-05-13

■ 結論

SQLiteは使えません。
なので、 PostgreSQL を使用するよう設定します。

■ 経緯

Herokuにデプロイ時、エラーが出た。

terminal
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.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to hoge-hoge-00000.
remote:
To https://git.heroku.com/hoge-hoge-00000.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hoge-hoge-00000.git'

SQLite3 周りでエラーが出る。。。

■ 原因・解決

heroku だと、 sqlite3 がビルドできないので、開発環境でだけ使うよ、っていう宣言が必要
 (heroku では、 production の gem だけビルドされる)

↓を削除し

gemfile


gem 'sqlite3'

代わりに↓を挿入する

gemfile


gem 'sqlite3', groups: %w(test development), require: false

gem 'pg', groups: %w(production), require: false

上記のようにGemfileを修正後、 bundle install && git push heroku master で完了!

■ 参考

36
28
6

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
36
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?