##開発環境
ubuntu(wsl)
Ruby 2.5
Rails 5.2
##エラー内容
bin/rails db:create
を実行すると
Could not find gem 'pg (>= 0.18, < 2.0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
言われてた通りbundle install
を実行すると、
An error occurred while installing pg (1.2.2), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.2' --source 'https://rubygems.org/'` succeeds before bundling.
gem install pg -v 1.2.2
を確認しろとのことなので、gem install pg -v 1.2.2
を実行する。
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.2.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-1.2.2 for inspection.
Results logged to /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.2.2/gem_make.out
##解決策
下記のコマンドを実行して、その後gem install pg -v 1.2.2
をする。
sudo apt install libpq-dev
###参考文献