Docker-php-ext-install error, exited with 123(Directory nonexistent)

docker

#1

For this command in the build step:
sudo docker-php-ext-install pdo_mysql

Started getting this error today:
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/ /usr/local/bin/docker-php-ext-enable: 108: /usr/local/bin/docker-php-ext-enable: cannot create /conf.d/docker-php-ext-pdo_mysql.ini: Directory nonexistent Exited with code 123

I building with below (without cache)
circleci/php:7.2-node-browsers
circleci/mysql:5.7

By the way, I got similar errors as topic26722 yesterday.
topic26722: Apt-get error, exited with code 100
Then today, no error occurred with api update, but instead this issue appeared.
I guess both error is a image file problem.

Anyone encounter anything similar?


#2

I’m getting the exact same issue in the following step with me and on the exact same php image:

      - run:
      name: PHP Extensions
      command: sudo docker-php-ext-install gd

This issue could be related to issues with images that were happening yesterday. See Image circleci/php:5.6-apache-node doesn't work anymore
@rohara I’m not sure if the issue is related.

One workaround that may work for you is running with the -E flag. e.g. sudo -E docker-php-ext-install pdo_mysql.


#3

I don’t know if it’s a coincidence but adding the -E flag worked for me, why?


#5

This is because for some reason, environment variables are no longer available to sudo.


#6
usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-u user] [VAR=value] [-i|-s] [<command>]
  -E, --preserve-env          preserve user environment when running command```

#7

@rohara Are there going to be any image changes that make env variables available to sudo without the -E flag as this was the case several days ago? Particularly with circleci/php:7.2-node-browsers.


#8

Good timing, I just found the problem.

The upstream PHP image changed this line in the enable script:

In the latest version of circleci/php:5.6.37-apache-node I confirmed that’s the issue by commenting out the new line and adding back in the old one. Here’s what I have for lines 108 and 109 now:

        ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
        #ini="$PHP_INI_DIR/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"

The sudo without -E worked as expected.

The reason for this is $PHP_INI_DIR is only defined for the circleci user, not root.

I’m looking into the best way to solve this right now.


#9

Okay found a nice, simple fix:

We’ll get that deployed ASAP, but don’t hold your breath since it’s a several hour process to do that.


#10

@rohara Thanks very much!


#11

It’s works! Thanks for quick response :+1:


#12