railsアプリ完成後にherokuでデプロイしようとしましたが、エラーが出てしまいデプロイできません。
参考にしたサイトは以下です。
https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39
私の行った手順は以下です。(参考サイトとほぼ同じです。)
(1)gemfileの設定
gemfileのgem 'sqlite3'をコメントアウトして、group :development, :test do ~~ end内にgem 'sqlite3'
を追記。
group :development, :test do gem 'sqlite3' ... end
(2)デプロイする予定であるherokuではPostgreSQL対応なので以下のコード追記
group :production do gem 'pg' end
gemfile全体図
source 'https://rubygems.org' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.6' # Use sqlite3 as the database for Active Record # gem 'sqlite3' # Use Puma as the app server gem 'puma', '~> 3.7' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # ユーザーの新規登録・ログイン機能を簡単に作成 gem 'devise' # フロントデザインはbootstrap使用 gem 'bootstrap', '~> 4.1.3' # Bootstrapを使うために必要なライブラリ gem 'jquery-rails' # xxxxxxx gem "font-awesome-sass" # ファイルを簡単かつ非常に柔軟にアップロード gem 'carrierwave', '~> 1.0' #画像編集 gem 'mini_magick' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'sqlite3' gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' gem 'selenium-webdriver' end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :production do gem 'pg' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
(2)gemfileの設定後にbundle install
shell
1bundle install --without production
(3)config/datebase.ymlの設定
production: <<: *default adapter: postgresql encoding: unicode pool: 5
(4)config/environments/production.rbの設定
config.assets.compile = true
(5)heroku設定後にデプロイ (gitコミット後に)
すると以下のエラーが出てしまい、上手くいきません。
略 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: !
エラー文にはherokuはsqlite3をサポートしてませんよ。と記載されています。
ですが、それを見越してproduction環境ではpostgresqlを使用するように以上のように設定したはずです。
それなのに、なぜ上手く作動しないのかわかりません。
原因を確かめるため、以下のようなテストを行ってみましたが、
問題の解決には至りませんでした。
1、gemfileのBundle installを再度行う
なお、私の環境は以下の通りです。
■ Rails 5.1.6
■ Ruby 2.5.0
■ git 2.17.2
■ heroku/7.19.3 darwin-x64 node-v11.3.0
他に必要な情報があれば、意見ください。
回答1件
あなたの回答
tips
プレビュー