困っていること
Rails 6 で、rails s や rails db:migrate などのコマンドを打つと次のようなエラーがでます。
rails aborted! LoadError: Error loading the 'postgresql' Active Record adapter. Missing a gem it depends on? pg is not part of the bundle. Add it to your Gemfile. bin/rails:4:in `require' bin/rails:4:in `<main>' Caused by: Gem::LoadError: pg is not part of the bundle. Add it to your Gemfile. bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace)
どういう意味なのでしょうか。
前提
よくわかってないですが、次のコマンドでRailsアプリを作成しました。
$ rails new [アプリケーション名] -d postgresql
Gemfileは、次の通りです。
ruby
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.6.6' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 6.0.3', '>= 6.0.3.2' 8# Use postgresql as the database for Active Record 9# gem 'pg', '>= 0.18', '< 2.0' 10# Use Puma as the app server 11gem 'puma', '~> 4.1' 12# Use SCSS for stylesheets 13gem 'sass-rails', '>= 6' 14# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 15gem 'webpacker', '~> 4.0' 16# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 17gem 'turbolinks', '~> 5' 18# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 19gem 'jbuilder', '~> 2.7' 20# Use Redis adapter to run Action Cable in production 21# gem 'redis', '~> 4.0' 22# Use Active Model has_secure_password 23# gem 'bcrypt', '~> 3.1.7' 24 25# Use Active Storage variant 26# gem 'image_processing', '~> 1.2' 27 28# Reduces boot times through caching; required in config/boot.rb 29gem 'bootsnap', '>= 1.4.2', require: false 30 31group :development, :test do 32 gem 'sqlite3', '1.4.1' 33 gem 'byebug', '11.0.1', platforms: [:mri, :mingw, :x64_mingw] 34end 35 36group :development do 37 gem 'web-console', '4.0.1' 38 gem 'listen', '3.1.5' 39 gem 'spring', '2.1.0' 40 gem 'spring-watcher-listen', '2.0.1' 41end 42 43group :test do 44 gem 'capybara', '3.28.0' 45 gem 'selenium-webdriver', '3.142.4' 46 gem 'webdrivers', '4.1.2' 47 gem 'rails-controller-testing', '1.0.4' 48 gem 'minitest', '5.11.3' 49 gem 'minitest-reporters', '1.3.8' 50 gem 'guard', '2.16.2' 51 gem 'guard-minitest', '2.4.6' 52end 53 54group :production do 55 gem 'pg', '1.1.4' 56end 57 58# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 59gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/15 17:57