Php: Error enabling pdo_pgsql with php:7.0 image

Created on 5 Apr 2018  路  5Comments  路  Source: docker-library/php

Hi there,

I'm having a little trouble enabling the pdo_pgsql extension in docker. I would appreciate any insight or help.

First part of my Dockerfile.

FROM php:7.0

RUN echo 'deb http://ftp.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list \
 && apt-get update \
 && apt-get install -y --no-install-recommends \
    libpq-dev \
    libxml2-dev \
    unzip \
 && apt-get -t jessie-backports install -y --no-install-recommends \
    libav-tools \
 && rm -rf /var/lib/apt/lists/* \
 && docker-php-ext-install \
    pcntl \
    pdo \
    pdo_pgsql \
    pgsql \

Fails with
re2c: error: cannot open ext/pdo/pdo_sql_parser.re Makefile:201: recipe for target '/usr/src/php/ext/pdo/pdo_sql_parser.c' failed make: *** [/usr/src/php/ext/pdo/pdo_sql_parser.c] Error 1

This just started happening today. I believe after an upgrade from php 7.0.28 to php 7.0.29 in the image.

I was able to get it to successfully build by using the php:7.1 image instead of php:7.0. After lots of googling, I can't find any dependencies it's missing. How do I enable the pdo_pgsql extensions for this build?

Thanks!

Most helpful comment

@yosifkit pointed out to me that this isn't actually necessary -- PDO is included in the images already, so you should be able to simply do pdo_pgsql (without pdo) and it should work properly. :+1:

All 5 comments

Using the following simpler Dockerfile:

FROM php:7.0

RUN apt-get update && apt-get install -y libpq-dev \
    && docker-php-ext-install pdo pdo_pgsql

A bit more of the failure logs:

 cc -I. -I/usr/src/php/ext/pdo -DPHP_ATOM_INC -I/usr/src/php/ext/pdo/include -I/usr/src/php/ext/pdo/main -I/usr/src/php/ext/pdo -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/pdo/pdo_stmt.c  -fPIC -DPIC -o .libs/pdo_stmt.o
(cd /usr/src/php/ext/pdo; re2c --no-generation-date -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re)
re2c: error: cannot open ext/pdo/pdo_sql_parser.re
Makefile:201: recipe for target '/usr/src/php/ext/pdo/pdo_sql_parser.c' failed
make: *** [/usr/src/php/ext/pdo/pdo_sql_parser.c] Error 1
The command '/bin/sh -c apt-get update && apt-get install -y libpq-dev  && docker-php-ext-install pdo pdo_pgsql' returned a non-zero code: 2

This looks like a case of https://github.com/php/php-src/pull/2955. :disappointed:

@yosifkit pointed out to me that this isn't actually necessary -- PDO is included in the images already, so you should be able to simply do pdo_pgsql (without pdo) and it should work properly. :+1:

(I've also filed https://github.com/php/php-src/pull/3211 to see about adjusting the line of code in ext/pdo/Makefile.frag to be more forgiving of differing methods of compilation.)

Thank you!

Thanks :+1:

Was this page helpful?
0 / 5 - 0 ratings