Viewing the answer in this thread - How to install libpq-dev (14.0-1) on ubuntu 21.10? -
Just install the required version of libpq5 and reinstall libpq-dev:
sudo apt-get install libpq5=13.4-1
sudo apt-get install libpq-dev
How did the author know to set libpq5=13.4-1 ? I tried going over to the debian site https://www.debian.org/distrib/packages but was unable to figure out. For context, I want to install an older version of postgres with the libpq-dev dependency in an Ubuntu 18.04 (or Ubuntu 20.04) environment.
For extra context, I am looking to build a CI workflow around this - so you can think of this as needing to be done in a docker container, Github actions workflow, etc. A particular web framework being used by a legacy system (written in Ruby on Rails) has a specific version of a dependency (pg gem - https://rubygems.org/gems/pg/versions/0.18.4) that requires a specific version of postgres. For various reasons, we can't upgrade the legacy system at the moment.