Ubuntu Trusty doesn't have pdo_pgsql

php
postgresql
trusty

#1

Hello,

To be able to use PostgreSQL 9.5, I followed the following topic: Request: Postgres 9.5
So I switched my default container to the Trusty container, but then I had a few issues with my PHP dependencies.
I had to follow Ubuntu Trusty has no PECL support under PHP7 to be able to get pecl back and install apcu.
But pdo_pgsql is still missing, and I never had to install it manually before.
On Trusty, PHP seems to have been compiler with the following options:
'./configure' '--with-config-file-path=/opt/circleci/php/7.0.3/etc' '--with-config-file-scan-dir=/opt/circleci/php/7.0.3/etc/conf.d' '--prefix=/opt/circleci/php/7.0.3' '--libexecdir=/opt/circleci/php/7.0.3/libexec' '--with-gd' '--enable-sockets' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-exif' '--enable-zip' '--with-zlib' '--with-zlib-dir=/usr' '--with-kerberos' '--with-openssl' '--with-mcrypt=/usr' '--enable-soap' '--enable-xmlreader' '--with-xsl' '--enable-ftp' '--enable-cgi' '--with-curl=/usr' '--with-tidy' '--with-xmlrpc' '--enable-sysvsem' '--enable-sysvshm' '--enable-shmop' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-pdo-sqlite' '--enable-pcntl' '--with-readline' '--enable-mbstring' '--disable-debug' '--enable-fpm' '--enable-bcmath' '--enable-intl' '--with-apxs2=/usr/bin/apxs2' '--with-libdir=lib64'

Could you reuse the same options as the previous container?

Thank you


#2

@kimh Is it possible to add the option to have pdo_pgsql?

Thank you.


#3

@MiLk Yes, I can do that and sorry for missing the compile option. I’ll reviewing these compile options and rebuild all versions.

I’lll let you know once I rebuild with pdo_pgsql.


#4

I’m new to Circle and still learning the ropes as I work to get a CakePHP project working and I think I may be running into a similar/related issue.

my phpunit call is failing and the output I see in the web interface is…

phpunit
PHPUnit 5.3.4 by Sebastian Bergmann and contributors.

Exception: Unable to insert fixtures for "App\Test\TestCase\Controller\DepartmentsControllerTest" test case. SQLSTATE[HY000] [2002] No such file or directory in [/home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureManager.php, line 342]
PHPUnit 5.3.4 by Sebastian Bergmann and contributors.

When I ssh in and run it manually I get the same issue. Trying to run CakePHP’s bake tool–which connects to the database–provides more detail:

$ ./bin/cake bake model

Welcome to CakePHP v3.2.9 Console
---------------------------------------------------------------
App : src
Path: /home/ubuntu/PROJECT-NAME/src/
PHP : 5.6.17
---------------------------------------------------------------
Choose a model to bake from the following:
Exception: Database driver Cake\Database\Driver\Postgres cannot be used due to a missing PHP extension or unmet dependency in [/home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Database/Connection.php, line 169]
2016-05-19 18:21:34 Error: [Cake\Database\Exception\MissingExtensionException] Database driver Cake\Database\Driver\Postgres cannot be used due to a missing PHP extension or unmet dependency
Exception Attributes: array (
  'driver' => 'Cake\\Database\\Driver\\Postgres',
)
Stack Trace:
#0 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Database/Connection.php(108): Cake\Database\Connection->driver('Cake\\Database\\D...', Array)
#1 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Datasource/ConnectionRegistry.php(87): Cake\Database\Connection->__construct(Array)
#2 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Core/ObjectRegistry.php(93): Cake\Datasource\ConnectionRegistry->_create('Cake\\Database\\C...', 'default', Array)
#3 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php(202): Cake\Core\ObjectRegistry->load('default', Array)
#4 /home/ubuntu/PROJECT-NAME/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(913): Cake\Datasource\ConnectionManager::get('default')
#5 /home/ubuntu/PROJECT-NAME/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(875): Bake\Shell\Task\ModelTask->_getAllTables()
#6 /home/ubuntu/PROJECT-NAME/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(889): Bake\Shell\Task\ModelTask->listAll()
#7 /home/ubuntu/PROJECT-NAME/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(90): Bake\Shell\Task\ModelTask->listUnskipped()
#8 [internal function]: Bake\Shell\Task\ModelTask->main()
#9 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Console/Shell.php(456): call_user_func_array(Array, Array)
#10 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Console/Shell.php(450): Cake\Console\Shell->runCommand(Array, false)
#11 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(217): Cake\Console\Shell->runCommand(Array, true, Array)
#12 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(181): Cake\Console\ShellDispatcher->_dispatch(Array)
#13 /home/ubuntu/PROJECT-NAME/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(127): Cake\Console\ShellDispatcher->dispatch(Array)
#14 /home/ubuntu/PROJECT-NAME/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#15 {main}

From what I’ve read, my guess is that I’m running into the same issue (lack of pdo_pgsql), but I’d appreciate any guidance on what the issue is.


#5

I guess it’s the same issue and the driver for PostgreSQL is missing.


#6

I checked the options on the previous image and the following options are missing:
'--with-gmp' '--with-pdo-pgsql' '--with-ldap' '--enable-calendar' '--with-bz2' '--with-exif' '--with-gettext' '--enable-phar' '--with-pear'


#7

I just rebuilt all php for our Trusty build image. I think I rebuilt with the same configure options used for Precise php. You can install the latest version by putting the following in the circle.yml.

machine:
  pre:
    - curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash
    - sudo apt-get install circleci-php-7.0.4

  php:
    version: 7.0.4

Please replace the version with your own. If this works, I’ll ship a new build image that preinstalls php so that you don’t have to manually install at every build.


#8

My build is successful with the following config:
machine:
pre:
- curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash
- sudo apt-get install circleci-php-7.0.4
php:
version: 7.0.4
services:
- postgresql
dependencies:
pre:
- sudo /opt/circleci/php/7.0.4/bin/pear config-set php_ini /opt/circleci/php/7.0.4/etc/php.ini
- sudo /opt/circleci/php/7.0.4/bin/pecl config-set php_ini /opt/circleci/php/7.0.4/etc/php.ini
- yes ‘’ | sudo /opt/circleci/php/7.0.4/bin/pecl install apcu-5.1.3
override:
- make deps
post:
- sudo service postgresql stop 9.4
- sudo cp -v /etc/postgresql/9.{4,5}/main/pg_hba.conf && sudo service postgresql restart 9.5

Thank you!


#9

Awesome! Then, I’ll preinstall the version in the build image very soon.


#10

Hi, I just shipped the new build image. Now you don’t have to install PHP manually to get the configure options. Please let me know if you see any problems.


#11

It works perfectly.

Thank you!


#12