Rails Postgres - db:test:prepare - could not open extension control file pg_stat_statements

using image: cimg/postgres:12.7
and installing client/contrib via:

      - run:
          name: Install Postgresql Client
          command: sudo apt install postgresql-client postgresql-contrib

Locally (and in other environments) extensions are enabled without issue, however here I always get this error when running bundle exec rails db:test:prepare

psql:/home/circleci/project/db/structure.sql:16: ERROR:  could not open extension control file "/usr/lib/postgresql/12/share/extension/pg_stat_statements.control": No such file or directory
rails aborted!
failed to execute:
psql -v ON_ERROR_STOP=1 -q -X -f /home/circleci/project/db/structure.sql cabal_test

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

Specifically, when SSHd into the box, I see that in /usr/lib/postgresql/12 there is no /shared directory

afaik I have everything needed installed, a bit stuck here and appreciate any input if anyone has seen this issue before

Hey @Cmarl ,

It looks like the CircleCI next-gen convenience image for Postgres (i.e., cimg/postgres) is missing extensions being installed.
There is an ongoing GitHub issue raised, and I can see a contribution PR attempt to fix this here.

For the time-being, i wonder if you can try changing the Postgres’ image to the official Postgres image and see if it works for you?

-     - image: cimg/postgres:12.7
+     - image: postgres:12.7

I can see on the official Postgres image that additional extensions are supported (See “Additional Extensions” section in Docker Hub), and the pg_stat_statements extension seems to be already included in v12.

Hi @Cmarl

Just reaching out to you, as I wanted to share that the issue was identified and resolved on Nov 4, 2021.
In other words, you should be able to revert to using the cimg/postgres:12.7 image and it should have pg_stat_statements extension available! :wave: