【Rails】An error occurred while installing pg (1.1.4), and Bundler cannot continue.時の対処法

<h2>症状</h2>
railsチュートリアルに載っていたGemの設定をコピペして、bundle updateをしたら、下記のエラーが表示され、正常にupdateできなかったようです。

Rails v6.0.3

```
 bundle update
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.....
Using rake 12.3.3
Using concurrent-ruby 1.1.8
Using i18n 1.8.9
Using minitest 5.11.3 (was 5.14.4)
Using thread_safe 0.3.6
Using tzinfo 1.2.9
Using zeitwerk 2.4.2
Using activesupport 6.0.3
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.5.0
Using racc 1.5.2
Using nokogiri 1.11.2 (x86_64-linux)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.9.0
Using rails-html-sanitizer 1.3.0
Using actionview 6.0.3
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 6.0.3
Using nio4r 2.5.7
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.3
Using actioncable 6.0.3
Using globalid 0.4.2
Using activejob 6.0.3
Using activemodel 6.0.3
Using activerecord 6.0.3
Using mimemagic 0.3.10
Using marcel 0.3.3
Using activestorage 6.0.3
Using mini_mime 1.0.3
Using mail 2.7.1
Using actionmailbox 6.0.3
Using actionmailer 6.0.3
Using actiontext 6.0.3
Using bundler 1.17.2
Using method_source 1.0.0
Using thor 1.1.0
Using railties 6.0.3
Using sprockets 3.7.2
Using sprockets-rails 3.2.2
Using rails 6.0.3
Fetching active_storage_validations 0.8.2
Installing active_storage_validations 0.8.2
Using public_suffix 4.0.6
Using addressable 2.7.0
Fetching ansi 1.5.0
Installing ansi 1.5.0
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching autoprefixer-rails 10.2.4.0
Installing autoprefixer-rails 10.2.4.0
Fetching aws-eventstream 1.1.1
Installing aws-eventstream 1.1.1
Fetching aws-partitions 1.436.0
Installing aws-partitions 1.436.0
Fetching aws-sigv4 1.2.3
Installing aws-sigv4 1.2.3
Fetching jmespath 1.4.0
Installing jmespath 1.4.0
Fetching aws-sdk-core 3.113.0
Installing aws-sdk-core 3.113.0
Fetching aws-sdk-kms 1.43.0
Installing aws-sdk-kms 1.43.0
Fetching aws-sdk-s3 1.46.0
Installing aws-sdk-s3 1.46.0
Fetching bcrypt 3.1.13
Installing bcrypt 3.1.13 with native extensions
Using bindex 0.8.1
Using msgpack 1.4.2
Using bootsnap 1.4.5
Using ffi 1.15.0
Using sassc 2.4.0
Fetching bootstrap-sass 3.4.1
Installing bootstrap-sass 3.4.1
Fetching will_paginate 3.1.8
Installing will_paginate 3.1.8
Fetching bootstrap-will_paginate 1.0.0
Installing bootstrap-will_paginate 1.0.0
Using byebug 11.0.1
Using regexp_parser 1.8.2
Using xpath 3.2.0
Using capybara 3.28.0
Using childprocess 2.0.0
Fetching coderay 1.1.3
Installing coderay 1.1.3
Fetching faker 2.1.2
Installing faker 2.1.2
Fetching formatador 0.2.5
Installing formatador 0.2.5
Using rb-fsevent 0.10.4
Using rb-inotify 0.10.1
Using ruby_dep 1.5.0
Using listen 3.1.5
Fetching lumberjack 1.2.8
Installing lumberjack 1.2.8
Fetching nenv 0.3.0
Installing nenv 0.3.0
Fetching shellany 0.0.1
Installing shellany 0.0.1
Fetching notiffany 0.1.3
Installing notiffany 0.1.3
Fetching pry 0.14.0
Installing pry 0.14.0
Fetching guard 2.16.2
Installing guard 2.16.2
Fetching guard-compat 1.2.1
Installing guard-compat 1.2.1
Fetching guard-minitest 2.4.6
Installing guard-minitest 2.4.6
Fetching mini_magick 4.9.5
Installing mini_magick 4.9.5
Fetching ruby-vips 2.1.0
Installing ruby-vips 2.1.0
Fetching image_processing 1.9.3
Installing image_processing 1.9.3
Using jbuilder 2.9.1
Fetching ruby-progressbar 1.11.0
Installing ruby-progressbar 1.11.0
Fetching minitest-reporters 1.3.8
Installing minitest-reporters 1.3.8
Fetching pg 1.1.4
Installing pg 1.1.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/pg-1.1.4/ext
/home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/ruby -I /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0 -r ./siteconf20210329-4274-geu1jf.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/$(RUBY_BASE_NAME)
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ubuntu/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/pg-1.1.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/pg-1.1.4 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/pg-1.1.4/gem_make.out

An error occurred while installing pg (1.1.4), and Bundler cannot continue.
Make sure that `gem install pg -v '1.1.4' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  pg
```

最後のほうにある「An error~」を翻訳に放り込むと、
<b>「pg（1.1.4）のインストール中にエラーが発生し、Bundlerを続行できません。
バンドルする前に、 `gem install pg -v '1.1.4' --source'https：// ruby​​gems.org / '`が成功することを確認してください。」</b>
となりました。

メッセージの通り、gem install pg -v '1.1.4' --source 'https://rubygems.org/を実施しましたが、解決しませんでした。



<h2>解決策</h2>
bundle install --without production後に、bundle updateしたら治りました。
なぜ治ったかは不明。。。

```
#エラーが出る
bundle install --without production

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
You have requested:
  minitest = 5.11.3

The bundle currently has minitest locked at 5.14.4.
Try running `bundle update minitest`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

#updateが正常に完了できる
bundle update
```

<h2>参考</h2>
Railsチュートリアル13章
https://railstutorial.jp/chapters/user_microposts?version=6.0#code-final_gemfile