Php: docker-php-ext-install intl fails

Created on 18 Dec 2014  路  50Comments  路  Source: docker-library/php

Hi Guys,

I have been trying to enable the intl extension and I have been running into troubles as it keeps failing.

I get:

checking for icu-config... no
checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

I fixed this by running:
apt-get install libicu-dev

Rerunning the docker-php-ext-install intl then fails again with the following:

Checking whether g++ accepts -g... no
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/usr/src/php/ext/intl':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

Is this a bug? The container doesn't appear to have the C++ compiler installed.
To fix i used:
apt-get install g++

Now the extension installs as expected.

I am using php:5.6-apache for reference.

Hope this helps.

Thanks,
Rob

Most helpful comment

A working example:

FROM php:5.6
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl


All 50 comments

That is as expected. We only install the minimal requirement to run php; any dependencies of extra modules you add would need to be added as well. Some packages could just be required for building the new module and could then be combined in one RUN line so that an apt-get purge could remove the items no longer needed.

Adding g++ seems reasonable though, IMO, since it's needed to compile some
of the core modules.

Thanks for the response, I would say from an outsiders point of view that the name "docker-php-ext-install" to me at least indicates that the script is installing the extension and any dependencies.

The issue is that unless you know which dependencies are required to install an extension you end up running it several times to find out where it fails and then google the error :-) .

Im not suggesting that you should add every dependency under the sun to the container, I am just explaining that the current implementation has some confusion to it.

I don't like describing a problem unless I can suggest something to resolve it although this is a difficult one.

So here are some suggestions:

  1. Add an inline message at install time to say that this could fail if you do not install the dependencies. (Better than letting it fail without knowing why)
  2. When an extension is added to the container, store the list of dependencies required and run an apt-get against them. (If you want to install the extension you are going to need them!)
  3. The same as number 2 but maybe with a flag to either install or not install the dependencies incase you want to manually control this.

I am just trying to think of ways of removing barriers for people who want to use the image but then get stuck when they need to install the dependencies.

If I can help at all with the documentation for docker-php-ext-install let me know as I only stumbled upon this by accident reading the other issues.

I'm not sure but after facing the same problem (solved in the same way @robbydooo did) I've realized that Symfony Standard Edition (through its symfony/intl component) and CakePHP >= 3 both depend on intl php extension.

I've found some references to intl extension in Zend2 and Wordpress as well. Then considering that some important PHP frameworks/libs require (or at least make use of this extension) this extension it could be interesting make it easier to enable it.

What do you think guys?

+1 for intl available by default.

Random thrown in suggestion, why include a manifest of extensions in addition to the script that provides preinstall and postinstall commands (g++ isnt likely to be needed AFTER intl is installed so may as well remove it and clean up after install)

+1 same fail. And +1 to enable intl by default !

I don't think it would be a good idea to enable intl be default.

I use docker for development only, so I might see things from a different perspective, but I like having to deal with my dependencies. It allows me to have a good idea of what has to be installed at the production environment. Silently installed dependencies could lead to a missing dependency on production.

Even if it's not included by default, it would be cool if we provide an example of a way to install it (docment an example Dockerfile or something).

A working example:

FROM php:5.6
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl


I agree that it is not the requirement to install by default as such but I would expect docker-php-ext-install/docker-php-ext-configure to not die in the current way.

To me it doesn't make sense to have a tool that should install libraries fail because the required dependancies are not installed. I would expect it to at least throw a useful error (E.g run apt get install XYZ).

Maybe there should be another script docker-php-install-ext-dependencies that docker-php-ext-install could call if they are not installed to handle this issue.

Based on the required extensions it could build a list of dependencies to install and install them. You could then add a flag to the docker-php-ext-install such as --install-dependencies to auto handle this.
That way people that wish to handle the dependencies manually can do so and the other people can benefit from an easy install.

What do you think?

I agree it's not easy to know what went wrong and which package to install in order to get an extension to work.

But It should be the php (pecl) docs role, not docker-php-ext-*.

Same problem from my side.

I just ran into this issue, i'm just wondering if we shouldn't just list the available extensions and what dependencies need to be installed to have it compile.

Agreed, +1 intl

In case this helps anyone else, @docteurklein's Dockerfile config didn't quite work for me (Docker Toolbox 1.12.0 on Windows 10) but it did successfully install intl when I tweaked it a tiny bit:

FROM php:5.6-apache

RUN apt-get update \
  && apt-get install -y zlib1g-dev libicu-dev g++ \
  && docker-php-ext-configure intl \
  && docker-php-ext-install intl

Symfony recommends Intl, so it'd be quite nice to have intl in default container setup

Guys, I really don't believe one have to install g++ to install intl. I guess libicu-dev is enough.

@mikemix you guess or you're sure? Pretty sure I put g++ for a reason, I wouldn't include it for the fun of it :)

+1 enable intl by default

Well, at least this thread is one of the top results when you google the error message. Thanks guys.

+1 enable intl by default

+1 to enable intl by default

how is it for alpine? if i may

@cordoval Per the gitHub Dockerfile for 7.2-rc-alpine intl is not enabled.

i just wanted a solution for alpine not force any intl onto the core.

I resolved it.

@cordoval how did you solve this, please share with the community your solution?

ok i will paste it here:

FROM php:7.0.21-fpm-alpine

RUN set -xe \
    && apk add --update \
        icu \
    && apk add --no-cache --virtual .php-deps \
        make \
    && apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        zlib-dev \
        icu-dev \
        g++ \
    && docker-php-ext-configure intl \
    && docker-php-ext-install \
        intl \
    && docker-php-ext-enable intl \
    && { find /usr/local/lib -type f -print0 | xargs -0r strip --strip-all -p 2>/dev/null || true; } \
    && apk del .build-deps \
    && rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/*

COPY performance.ini /usr/local/etc/php/conf.d/

WORKDIR /var/www

RUN rm -rf /var/www/*

if you guys find improvements to this let me know so i can retrogain as well 馃憤

@mikemix @docteurklein
I can confirm g++ is not required for me

FROM  php:7.2-rc-apache
RUN apt-get -y update \
    && apt-get install -y libicu-dev\
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl

works fine for me.

I still have an issue with the image php:7.2-apache.

@mrgrain I don't have any error with your solution during the build, but intl doesn't seem to be installed or activated properly after the build is completed (php -i | grep intl or php -m)...

Does anyone manage to make it work on the debian stretch image?

@nicogommen I'm not able to reproduce: :confused:

$ docker pull php:7.2-apache
7.2-apache: Pulling from library/php
Digest: sha256:b2cc1f9dead1c87b60b0961b0d163a8a4c0a028f01138d8a8225f2f946948113
Status: Image is up to date for php:7.2-apache

$ docker run -it --rm php:7.2-apache bash
root@4fe792fb131a:/var/www/html# apt-get update -qq
root@4fe792fb131a:/var/www/html# apt-get install -yqq libicu-dev > /dev/null
debconf: delaying package configuration, since apt-utils is not installed
root@4fe792fb131a:/var/www/html# docker-php-ext-install intl > /dev/null
/usr/src/php/ext/intl/idn/idn.c: In function 'php_intl_idn_to':
/usr/src/php/ext/intl/idn/idn.c:227:4: warning: 'uidna_IDNToASCII_57' is deprecated [-Wdeprecated-declarations]
    converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
    ^~~~~~~~~~~~~~~~~
In file included from /usr/include/unicode/platform.h:23:0,
                 from /usr/include/unicode/ptypes.h:50,
                 from /usr/include/unicode/umachine.h:44,
                 from /usr/include/unicode/utypes.h:36,
                 from /usr/include/unicode/uidna.h:20,
                 from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:673:1: note: declared here
 uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
 ^
/usr/src/php/ext/intl/idn/idn.c:229:4: warning: 'uidna_IDNToUnicode_57' is deprecated [-Wdeprecated-declarations]
    converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
    ^~~~~~~~~~~~~~~~~
In file included from /usr/include/unicode/platform.h:23:0,
                 from /usr/include/unicode/ptypes.h:50,
                 from /usr/include/unicode/umachine.h:44,
                 from /usr/include/unicode/utypes.h:36,
                 from /usr/include/unicode/uidna.h:20,
                 from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:720:1: note: declared here
 uidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
 ^
root@4fe792fb131a:/var/www/html# php -i | grep -i intl
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0
root@4fe792fb131a:/var/www/html# 

Hi @tianon
I don't know exactly what I did, but it is now working fine.
Thanks for the answer.

For those who care about having the latest icu data available, it's rather straight forward to compile it in. See an example here: https://github.com/jakzal/docker-symfony-intl/blob/master/7.2/61.1/Dockerfile

FROM php:7.2-cli

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV BUILD_DEPS="autoconf file g++ gcc libc-dev make pkg-config re2c"
ENV LIB_DEPS="zlib1g-dev"
ENV ICU_RELEASE=61.1
ENV CXXFLAGS "--std=c++0x"

RUN apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS $LIB_DEPS && rm -rf /var/lib/apt/lists/* \
 && echo "date.timezone=Europe/Warsaw" >> $PHP_INI_DIR/php.ini \
 && docker-php-ext-install zip \
 && cd /tmp && curl -Ls http://download.icu-project.org/files/icu4c/$ICU_RELEASE/icu4c-$(echo $ICU_RELEASE | tr '.' '_')-src.tgz > icu4c-src.tgz \
 && cd /tmp && tar xzf icu4c-src.tgz && cd /tmp/icu/source && sed -i'' 's/define U_USING_ICU_NAMESPACE 0/define U_USING_ICU_NAMESPACE 1/g' common/unicode/uversion.h && ./configure && make && make install && rm -rf /tmp/icu /tmp/icu4c-src.tgz \
 && docker-php-ext-configure intl && docker-php-ext-install intl \
 && curl -Ls https://getcomposer.org/composer.phar > /usr/local/bin/composer && chmod +x /usr/local/bin/composer \
 && apt-get purge -y --auto-remove $BUILD_DEPS

CMD icu-config --version && php -i | grep 'ICU version'

I wouldn't use those images directly, as they're meant to provide various icu versions for Symfony development. I'd rather replicate similar steps in your own images.
You could also test them out by copying the lib and extension from my images (just tweak php and icu versions to your needs, and test it thoroughly):

FROM php:7.2-fpm

COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/libicu* /usr/local/lib/
COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/icu /usr/local/lib/icu
COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/php/extensions/no-debug-non-zts-20170718/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/intl.so
RUN docker-php-ext-enable intl

I got same error on php:7.2-apache (Debian GNU/Linux 9 stretch)
Installed libicu-dev then I can install intl.

FROM php:7.2-apache

RUN apt-get update -y && apt-get install -y \
  libicu-dev \
  && docker-php-ext-configure intl \
  && docker-php-ext-install intl

Intl should not be installed by default. also if some frameworks like Cake or Symfony (that I'm using and that is the reason why I landed on this issue) require it, it is not a mandatory package.

For example, with Symfony, if you develop a CLI app, there are 99% of possibilities you don't need the Intl extension.

And also if you develop a web app, the Intl extension is only required by validators:

docker-symfony-requirements-min

So, my point is to provide clear and definitive examples of how to install the Intl ext, but not including it by default as it is not always required.

My 2 cents.

+1 to enable intl by default

Don't put anything by default. One can install everything easily. The image should be as skinny as possible. Also please don't create (up/down)vote posts, stick to emoji please.

Installation is really easy:

RUN apt-get update && apt-get install -y --no-install-recommends libicu-dev \
    && docker-php-ext-install intl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* || true

Hi, Is this configuration still working for you? I'm using php:7.1-fpm as my base image and when I follow the installation of intl I get this warning:

/usr/src/php/ext/intl/idn/idn.c: In function 'php_intl_idn_to':
/usr/src/php/ext/intl/idn/idn.c:229:4: warning: 'uidna_IDNToASCII_57' is deprecated [-Wdeprecated-declarations]
converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
^~~~~
In file included from /usr/include/unicode/platform.h:23:0,
from /usr/include/unicode/ptypes.h:50,
from /usr/include/unicode/umachine.h:44,
from /usr/include/unicode/utypes.h:36,
from /usr/include/unicode/uidna.h:20,
from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:673:1: note: declared here
uidna_IDNToASCII( const UChar* src, int32_t srcLength,
^
/usr/src/php/ext/intl/idn/idn.c:231:4: warning: 'uidna_IDNToUnicode_57' is deprecated [-Wdeprecated-declarations]
converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
^~~~~
In file included from /usr/include/unicode/platform.h:23:0,
from /usr/include/unicode/ptypes.h:50,
from /usr/include/unicode/umachine.h:44,
from /usr/include/unicode/utypes.h:36,
from /usr/include/unicode/uidna.h:20,
from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:720:1: note: declared here

I tried with zlib1g-dev libicu-dev g++ as @Tocacar suggested and also the simple install by @mikemix. Both generate this warning.

I just built it against php:7.1-apache without any problems.

@anacicconi on some platforms with the most recent ICU versions I had to do sed -i'' 's/define U_USING_ICU_NAMESPACE 0/define U_USING_ICU_NAMESPACE 1/g' common/unicode/uversion.h in the ICU sources before ./configure was run

Upstream has an RFC to track the IDNToASCII (idna) deprecation: https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003

It looks like work to implement the deprecation is already underway but hasn't been released yet.

https://github.com/php/php-src/commit/8a4c2f16217fb8f8d098355f3943f31e82bcfd71
https://github.com/php/php-src/commit/01912f93c3f702b5b34a0a9a4c8f529785b0286a

If @jakzal's workaround fails in later ICU releases (if/when the icu devs remove the idna code instead of deactivating it in a header file) cherry-picking/backporting those two commits might be worth a shot.

Are there any accumulated list of scripts for enabling php extensions in docker php images (jessie,stretch and alpine)? that we can use to easilies make our docker image work, (and not need to be a linux machine nerd?)

@joelharkes There isn't any list as such since it would never be complete. @tianon wrote this blog post and explained how he figures out deps in https://github.com/docker-library/php/issues/75#issuecomment-353673374.

See also https://github.com/mlocati/docker-php-extension-installer for an attempt to create/maintain such a list (no Alpine support currently).

Hi,

I am facing ERROR: intl is required though i have tried by commenting the extension=php_intl.dll extension file in php.ini file. I can see php_intl.dll file in ext folder of php.

Please help me to solve the issue.

Thank You:)

I'm not sure this is a right place for a help request.

A working example:

FROM php:5.6
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl

Thanks, I confirm this is working now!

@Gasgeber FYI, PHP 5 is end of life (https://secure.php.net/supported-versions.php).

Not only that, PHP7 is significantly faster.

Yet, there's still no official php docker that ships with all dependencies, unless you make your own... so too bad if you're on a bad connection and have a slow cpu...

A working example:

FROM php:5.6
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl

thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nojimage picture nojimage  路  3Comments

solocommand picture solocommand  路  3Comments

ktrzos picture ktrzos  路  3Comments

cordoval picture cordoval  路  3Comments

pukkancs picture pukkancs  路  3Comments