Installing the ruby PG gem requires Postgres to be instaled locally to install the gem, which is annoying and unnecessary if you're building inside of docker.
An error occurred while installing pg (1.2.3), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.3' --source 'https://rubygems.org/'` succeeds before bundling.
The Original Article.
sudo apt update
sudo apt install libpq-dev
Then you can install the gem:
gem install pg -- --with-opt-dir="/usr/local/opt/libpq"
The following packages have unmet dependencies.
libpq-dev : Depends: libpq5 (= 12.7-0ubuntu0.20.10.1) but 13.3-1.pgdg20.10+1 is to be installed
E: Unable to correct problems, you have held broken packages.
Any newer version of libpq5 can cause this error. In my case it was libpq5=13.1-1.pgdg20.10+1
.
sudo apt install libpq5=12.7-0ubuntu0.20.10.1
and then install liqpq-dev again
sudo apt install libpq-dev