Skip to content

iconv on Alpine 3.13 #1121

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

Closed
enumag opened this issue Jan 19, 2021 · 14 comments
Closed

iconv on Alpine 3.13 #1121

enumag opened this issue Jan 19, 2021 · 14 comments

Comments

@enumag
Copy link

enumag commented Jan 19, 2021

Using the PHP alpine images, this code...:

<?php
ini_set('display_errors', '1');
error_reporting(-1);
iconv("UTF-8", "ASCII//TRANSLIT", "foobar");

...causes this error:

iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT' is not allowed in [...]

This is a long-known issue, however the situation has changed significantly so I think a new issue is appropriate.

Until now the problem was commonly solved by this workaround:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

This however no longer works with gnu-libiconv 1.16-r0 because the preloadable_libiconv.so has been removed (see alpine aports issue and related libiconv commit).

On Alpine 3.12 we can use gnu-libiconv=1.15-r2.

On Alpine 3.13 however the version no longer exists and consequently the workaround is not available.

EDIT: My bad. The version is available in 3.13, just missing in edge.

Is there any other way to fix this? Perhaps somehow using --with-iconv when building PHP? (Not sure, just an idea.)

@khs1994
Copy link

khs1994 commented Jan 19, 2021

RUN apk add --no-cache  gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

@enumag
Copy link
Author

enumag commented Jan 19, 2021

Ah okay so it only doesn't work with edge for now but v3.13 will be fine. Good to know but still it means that the current workaround might not work later.

@greg0ire
Copy link

greg0ire commented Feb 1, 2021

To anyone visiting this issue, the current workaround is

-apk add gnu-libiconv
+apk add gnu-libiconv=1.15-r2

@gouki777
Copy link

I looked at the documentation , used 3.12 is good. thanks~

FROM alpine:3.12
RUN     apk update && \
        apk add php7=7.3.27-r0 php7-iconv 
		.............................		
#fix apline-php7-iconv
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv=1.15-r2
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
cmd["php"]

@litan1106
Copy link

my current workaround is the stick with alpine3.13 and gnu-libiconv=1.15-r3

@thekid
Copy link

thekid commented Jul 12, 2021

my current workaround is the stick with alpine3.13 and gnu-libiconv=1.15-r3

For easy copy&pasting:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3

ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

@IStranger
Copy link

IStranger commented Jul 26, 2021

I have the same problem on Alpine 3.14 with php7.4. However, preloadable_libiconv.so was removed from 3.14:
https://pkgs.alpinelinux.org/contents?file=&path=&name=gnu-libiconv&branch=v3.14&repo=community&arch=x86_64

You can just install the same extensions from 3.13 repo:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

It works great!

@litan1106
Copy link

I got the same problem on Alpine 3.14 with php7.4. However, preloadable_libiconv.so was removed from 3.14:
https://pkgs.alpinelinux.org/contents?file=&path=&name=gnu-libiconv&branch=v3.14&repo=community&arch=x86_64

You can just install the same extensions from 3.13 repo:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

It works great!

are you using php-7.4 with alpine 3.14? then install the gnu-libiconv from 3.13 repo?

@IStranger
Copy link

IStranger commented Jul 26, 2021

are you using php-7.4 with alpine 3.14? then install the gnu-libiconv from 3.13 repo?

Yes. I'm using php:7.4.21-fpm-alpine3.14 image from hub.docker.com. Latest php release was implemented on 3.14, it is not my choice)

@josefsabl
Copy link

I have the same problem on Alpine 3.14 with php7.4. However, preloadable_libiconv.so was removed from 3.14: https://pkgs.alpinelinux.org/contents?file=&path=&name=gnu-libiconv&branch=v3.14&repo=community&arch=x86_64

You can just install the same extensions from 3.13 repo:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

It works great!

I confirm it also works with 3.15 at this time.

@duiniwukenaihe
Copy link

我在使用 php7.4 的 Alpine 3.14 上遇到了同样的问题。但是,preloadable_libiconv.so已经从 3.14 中删除:https://pkgs.alpinelinux.org/contents?file=&path=&name=gnu-libiconv&branch=v3.14&repo=社区&arch=x86_64
您可以从3.13 repo 安装相同的扩展:

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

效果很好!

我确认此时也适用于3.15。

Are you sure this will work on Alpine 3.15?I tried it and it failed:

https://github.com/richarvey/nginx-php-fpm/issues/262

@jdreesen
Copy link

This should not be necessary anymore, as it has been fixed here: #1264

@duiniwukenaihe
Copy link

thanks i know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests