Failing to add php7.1-pgsql

I’m trying to run phpunit tests against a postgres database. The tests fail with a PDOException: could not find driver. I believe this is because I’m missing the postgres driver.

When I run sudo apt-get install -y php7.1-pgsql I can’t locate the package.

The /etc/apt/sources.list file is locked down, so I’m unable to add an repositories.

sudo echo "deb http://ftp.de.debian.org/debian stretch main" >> /etc/apt/sources.list
bash: /etc/apt/sources.list: Permission denied

I’m pretty stumped at this point.

Get an SSH session at the end of your failed build, and experiment with searching for the module you need:

apt-cache search psql | grep php

Sometimes they are named unexpectedly, so try a few things.

What build image are you using? (Always add this please when asking repo questions).

Good point about the image. I’m using php:7.1-fpm-stretch-node-browsers.
Unfortunately, it looks like there’s isn’t a php postgres tool available.

circleci@df31bbf1073a:~$ sudo apt-cache search postgres | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search psql | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search pgsql | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search postgres | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search postgresql | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search gres | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search sql | grep php
circleci@df31bbf1073a:~$ sudo apt-cache search php | grep postgres
circleci@df31bbf1073a:~$ sudo apt-cache search php | grep pgsql
circleci@df31bbf1073a:~$ sudo apt-cache search php | grep psql

I am thinking I’ll need to make a custom image. I’m a little surprised there’s no php developers using circle and postgres…

Did you try docker-php-ext-install, as per the MySQL demo I put out on another thread?

I forgot about that. Thanks.

In the end I had a couple of commands in a shell script to swallow the config errors.

- run: chmod a+x ./ci/wrap_err.sh
- run: ./ci/wrap_err.sh
#!/usr/bin/env bash

# execute command
sudo apt-get install postgresql-client libpq-dev
sudo docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql

The config errors these commands throw will halt the Circle Build, but the tools are in place and usable. I found one of them is a Debian bug, so who knows when it will make it to Ubuntu.

I tested a custom image with Centos as a base, but in the end that doesn’t make sense for testing b/c we’re using Ubuntu on the production environment.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.