New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-php-ext-install intl fails #57

Closed
robbydooo opened this Issue Dec 18, 2014 · 44 comments

Comments

Projects
None yet
@robbydooo

robbydooo commented Dec 18, 2014

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

@yosifkit

This comment has been minimized.

Member

yosifkit commented Dec 18, 2014

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.

@tianon

This comment has been minimized.

Member

tianon commented Dec 18, 2014

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

@robbydooo

This comment has been minimized.

robbydooo commented Dec 18, 2014

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.

@moacirosa

This comment has been minimized.

moacirosa commented Jan 28, 2015

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?

@psychowico

This comment has been minimized.

psychowico commented Feb 18, 2015

+1 for intl available by default.

@jacobalberty

This comment has been minimized.

jacobalberty commented Mar 10, 2015

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)

@baptistedonaux

This comment has been minimized.

Contributor

baptistedonaux commented Apr 14, 2015

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

@mbohal

This comment has been minimized.

mbohal commented May 12, 2015

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.

@docteurklein

This comment has been minimized.

docteurklein commented May 18, 2015

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).

@docteurklein

This comment has been minimized.

docteurklein commented May 18, 2015

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


@robbydooo

This comment has been minimized.

robbydooo commented May 18, 2015

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?

@docteurklein

This comment has been minimized.

docteurklein commented May 18, 2015

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-*.

@yosifkit yosifkit referenced this issue May 19, 2015

Merged

Add g++ #101

@tianon tianon closed this in #101 May 19, 2015

@fabarea

This comment has been minimized.

fabarea commented May 23, 2015

Same problem from my side.

@macnibblet

This comment has been minimized.

macnibblet commented Jul 15, 2015

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.

@ratacibernetica

This comment has been minimized.

ratacibernetica commented Jan 22, 2016

Agreed, +1 intl

@Tocacar

This comment has been minimized.

Tocacar commented Aug 7, 2016

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
@pculka

This comment has been minimized.

pculka commented Aug 24, 2016

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

@mikemix

This comment has been minimized.

mikemix commented Apr 21, 2017

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

@docteurklein

This comment has been minimized.

docteurklein commented Apr 21, 2017

@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 :)

@gsedubun

This comment has been minimized.

gsedubun commented May 4, 2017

+1 enable intl by default

@HeWhoWas

This comment has been minimized.

HeWhoWas commented May 14, 2017

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

@application2000

This comment has been minimized.

application2000 commented May 19, 2017

+1 enable intl by default

@davidjeddy

This comment has been minimized.

davidjeddy commented May 30, 2017

+1 to enable intl by default

@cordoval

This comment has been minimized.

cordoval commented Jul 25, 2017

how is it for alpine? if i may

@davidjeddy

This comment has been minimized.

davidjeddy commented Jul 25, 2017

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

@cordoval

This comment has been minimized.

cordoval commented Jul 25, 2017

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

I resolved it.

@davidjeddy

This comment has been minimized.

davidjeddy commented Jul 26, 2017

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

@cordoval

This comment has been minimized.

cordoval commented Jul 26, 2017

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 👍

@mrgrain

This comment has been minimized.

mrgrain commented Aug 17, 2017

@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.

@nicogommen

This comment has been minimized.

nicogommen commented Dec 28, 2017

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?

@tianon

This comment has been minimized.

Member

tianon commented Dec 28, 2017

@nicogommen I'm not able to reproduce: 😕

$ 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# 
@nicogommen

This comment has been minimized.

nicogommen commented Jan 15, 2018

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

@jakzal

This comment has been minimized.

jakzal commented Mar 28, 2018

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
@yousan

This comment has been minimized.

yousan commented Jul 30, 2018

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
@Aerendir

This comment has been minimized.

Aerendir commented Aug 28, 2018

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.

@spacedog4

This comment has been minimized.

spacedog4 commented Sep 5, 2018

+1 to enable intl by default

@mikemix

This comment has been minimized.

mikemix commented Sep 6, 2018

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
@anacicconi

This comment has been minimized.

anacicconi commented Sep 22, 2018

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.

@mikemix

This comment has been minimized.

mikemix commented Sep 24, 2018

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

@jakzal

This comment has been minimized.

jakzal commented Sep 24, 2018

@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

@hairmare

This comment has been minimized.

hairmare commented Sep 24, 2018

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.

php/php-src@8a4c2f1
php/php-src@01912f9

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.

@joelharkes

This comment has been minimized.

joelharkes commented Oct 5, 2018

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?)

@hairmare

This comment has been minimized.

hairmare commented Oct 6, 2018

@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 #75 (comment).

@tianon

This comment has been minimized.

Member

tianon commented Oct 6, 2018

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

JohnMica added a commit to JohnMica/docker-grav that referenced this issue Oct 27, 2018

added a few extenstions for PHP
considering that Grav can be used internationally, i've added the `intl` extension and it's auto configuration. 
also i've enabled the `intl` extenstion

- at least that is what i believe i did considering docker-library/php#57 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment