herokuにrails 5アプリをgit push heroku master
しようとすると、エラーが出てしまいます。
$ git push heroku master Counting objects: 210, done. Compressing objects: 100% (193/193), done. Writing objects: 100% (210/210), 49.54 KiB | 0 bytes/s, done. Total 210 (delta 52), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. remote: Detected buildpacks: Ruby,Node.js remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.4.2 remote: -----> Installing dependencies using bundler 1.15.2 ... 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: In Gemfile: remote: sqlite3 remote: 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 quiet-sands-44976. remote: To https://git.heroku.com/quiet-sands-44976.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/quiet-sands-44976.git'
やったこと
- herokuのセットアップ
heroku login gemfileに`gem 'pg'`を追加 sudo apt-get install libpq-dev bundle install
-
gemfileからsqlite3の削除。その後、
bundle install
-
依存関係の確認。gemfile.lockにsqlite3が含まれていないか確認。含まれていませんでした。
-
database.ymlの編集。production環境はもちろんのこと、他の環境からもsqliteを除外した。
config\database.yml
# SQLite version 3.x # # default: &default # adapter: sqlite3 # pool: 5 # timeout: 5000 # encoding: utf8 # # development: # <<: *default # database: db/development.sqlite3 # test: adapter: mysql2 encoding: utf8 database: aptnote_test pool: 5 username: user password: password host: localhost production: adapter: postgresql database: my_database_production pool: 5 timeout: 5000 development: adapter: mysql2 encoding: utf8 database: aptnote_development pool: 5 username: user password: password host: localhost # socket: /tmp/mysql.sock
- データベースのマイグレーション
以下コマンドを実行。
rake db:create
rake db:migrate
- herokuへのデプロイを再検証
heroku addons:create heroku-postgresql
git push heroku master # => エラー発生
参考にしたページ
RailsをHerokuにpushするときにsqlite3でエラーが起こる
Herokuにデータベースを用意しないDeployでDetected sqlite3 gem which is not supported on Heroku と言われました。 - Qiita
ruby on rails - Detected sqlite3 gem which is not supported on Heroku - Stack Overflow
SQLite on Heroku | Heroku Dev Center
Getting Started on Heroku with Rails 5.x | Heroku Dev Center
どうしたらよいでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/07 18:43