Skip to content
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

Install error "Unterminated preprocessor conditions" in php 8.3 #640

Open
FedericoHeichou opened this issue Nov 24, 2023 · 51 comments
Open

Comments

@FedericoHeichou
Copy link

The first if condition in Imagick.stub.php is not closed

class Imagick
{
#if MagickLibVersion > 0x628
public function optimizeImageLayers(): bool {}

This causes a installation error "Unterminated preprocessor conditions" in PHP 8.3

I'll submit a PR

@dinamic
Copy link

dinamic commented Jan 15, 2024

Just had the same issue happening. Here are steps to reproduce:

docker run -it --rm php:8.3-alpine sh
apk update
apk add imagemagick imagemagick-dev gcc make autoconf g++ 
pecl install imagick

@UtkuDalmaz
Copy link

Any solution?

@dinamic
Copy link

dinamic commented Feb 5, 2024

@UtkuDalmaz People have tried to get in touch with the maintainer over different communication channels to no avail. I'm sticking with PHP 8.2 for now. Have a look at the discussion here: #641

@Danack
Copy link
Collaborator

Danack commented Feb 8, 2024

Thanks. It should be fixed now in develop, but as it never seemed to be a problem on my machine, I can't guarantee that.

I've actually just removed the #if MagickLibVersion > 0x628 as the minimum version of ImageMagick is above that now.

I'll close this issue when I'm more confident it's fixed (aka github actions are passing), but that will require more poking and possibly dropping support for PHP < 7.0 as the gen_stubs.php tool seems to no longer support those. Probably appropriately.

@dinamic
Copy link

dinamic commented Feb 8, 2024

@Danack so happy to hear from you! I hope things are okay.

The issue is easily reproducible with a docker container:

docker run -it --rm php:8.3-alpine sh
apk update
apk add imagemagick imagemagick-dev gcc make autoconf g++ 
pecl install imagick

@tcubukcu
Copy link

@UtkuDalmaz People have tried to get in touch with the maintainer over different communication channels to no avail. I'm sticking with PHP 8.2 for now. Have a look at the discussion here: #641

Yes using php8.2 seems like the best solution for now. I tried it on version 8.2, there was no problem with the installation.

@ihabzee
Copy link

ihabzee commented Mar 7, 2024

any update on when this issue will be fixed?
Thanks!

@mashb1t
Copy link

mashb1t commented Mar 8, 2024

having the same issue in PHP 8.3 (running on M1/arm and Docker)

admdly added a commit to admdly/FOSSBilling that referenced this issue Mar 13, 2024
Remove `imagick` dependency from Docker image as not strictly required (dompdf/dompdf#3376) and to resolve issue with PHP 8.3 (Imagick/imagick#640).
BelleNottelling pushed a commit to FOSSBilling/FOSSBilling that referenced this issue Mar 13, 2024
* Remove Docker image imagick dependency

Remove `imagick` dependency from Docker image as not strictly required (dompdf/dompdf#3376) and to resolve issue with PHP 8.3 (Imagick/imagick#640).

* Update Docker image to PHP 8.3

* Move GD to required PHP extensions
@ricardomecca
Copy link

Not have updates?
I've been waiting for the PECL update with the correction for more than 3 months but so far nothing.

@pF-luis
Copy link

pF-luis commented Apr 3, 2024

Same issue here

@mathroc
Copy link

mathroc commented Apr 3, 2024

A small recap: the issue is fixed on develop but a new tag for this hasn't been published yet. The maintainers are aware of this. Meanwhile, it means your choices are:

  • use develop instead of a tagged version
  • keep using PHP 8.2
  • fork the extension and tag a release of your own

You can also subscribe to this issue notifications, someone will very likely announce it here when a new tag appears.

But it's not very useful to post comment to "+1" the issue, complain or ask for estimates on when this will happen

@pF-luis
Copy link

pF-luis commented Apr 3, 2024

It's a simple comment, no harm done 😘 Thanks for the recap tho, thought something might've happened since the last official info was about two month ago.

@yesidevelop
Copy link

Sometimes it works, sometimes it doesn't strange bug
I tried this way
RUN pecl install imagick
RUN docker-php-ext-enable imagick

kpine added a commit to kpine/docker-webtrees that referenced this issue Apr 12, 2024
Imagick Fails when using `--no-cache --ci`: Imagick/imagick#640
@renky
Copy link

renky commented Apr 25, 2024

For everybody who is using mlocati/php-extension-installer

RUN install-php-extensions imagick/imagick@master

nevertheless: it's only a workarround in my opinion.
It's now more than two months ago that I had a last look on this issue and in all projects where I used imagick I finally could switch to gd or gmagick without any problems when upgrading to PHP8.3... Until today - now I have a project where I have to stick with imagick and I just see: still the same issue...

I know - the solution above works. But sorry... for productive environments I don't see an untagged version as a stable solution - in a production environment I need deterministic build processes and installation behavior and for that it is indispensable to have a tagged version of all dependencies... Just for a shortime workaround, I would accept such a develop solution.

If this extension cannot ensure this any more, I guess it's really EOL because more and more people will switch. That's why I again suggest to share responsibility for such an important php extension. It's also an option to contact the php foundation to request about helping in maintaining. Maybe the interest is high enough in case of this extension.

On the other side: Where is the problem to just put a tag on it?

Thanks to everybody who is working on it.

@eminozlem
Copy link

bumping for visibility. I am waiting for imagick to upgrade my websites to php 8.3. Hope this gets resolved soon 🙏

WHM OS
AlmaLinux v8.9.0

@tommmoe
Copy link

tommmoe commented Aug 18, 2024

Makes sense as to why it works on my ryzen but doesn't make sense as to why it doesn't work on my m5 EC2 instances, which should be Xenon and that should be amd64.. I'll check out what it's building tomorrow..

@ErroneousBosch
Copy link

ErroneousBosch commented Aug 22, 2024

So it now no longer works for me, neither on the alpine image nor in a debian bookworm image, on the same machine that it was working on before, same x86_64 install, with the same commands that have worked previously, and using the same version of imagick (3.7.0). tried removing the php:8.3-alpine image and repulling, still not working.

@ErroneousBosch
Copy link

ErroneousBosch commented Aug 22, 2024

I can confirm that the following does work in 8.3:

docker run -it --rm php:8.3-alpine sh
apk update
apk add imagemagick imagemagick-dev gcc make autoconf g++ git
cd /tmp 
git clone https://github.com/Imagick/imagick.git 
pecl install /tmp/imagick/package.xml 

This builds from the master git branch rather than the pre-packaged release, which is now over two and a half years old -- Jan 2022. I suspect that until/unless they put out a new release, this is the workaround.

@bicpi
Copy link

bicpi commented Sep 2, 2024

In case this might helps someone else to get unblocked from imagick issues: we got independent of it by migrating our use cases to libvips, using the php-vips package. It works very well and is even faster while consuming less memory.

@StrangePeanut
Copy link

@bicpi is that a drop in replacement for imagick? Alternatives have always existed but fail to pass imagick presence check which renders them useless for many of us.

@bicpi
Copy link

bicpi commented Sep 2, 2024

@StrangePeanut No, it has a different API, see the docs. But after re-working, the imagick extension is not needed anymore.

But of course this is only possible when controlling all Imagick usage, not when dependent packages or e.g. a CMS requires it.

@FedericoHeichou
Copy link
Author

In case this might helps someone else to get unblocked from imagick issues: we got independent of it by migrating our use cases to libvips, using the php-vips package. It works very well and is even faster while consuming less memory.

Seems cool. If it is really as described would be nice to create a wrapper

@Mr-Maniac
Copy link

I also wanted to report that imagick sometimes builds correctly on php 8.3 bookworm image. The last month it seems to have been building correctly almost every time.
But today I had a 50/50 chance (in a pipeline - same runner).
Very strange, indeed, that it succeeds sometime....

@juhasev
Copy link

juhasev commented Sep 14, 2024

I managed to get this working on Amazon Linux 2023 with PHP 8.3. Here is the docker file for anybody who might need it!

FROM amazonlinux:2023

ARG IMAGICK_PHP83_FIX_COMMIT=9df92616f577e38625b96b7b903582a46c064739

ENV TERM=xterm-256color
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME=/var/www/html
ENV PATH=$PATH:vendor/bin:/usr/local/bin

RUN yum install -y \
    ruby \
    nodejs \
    php-pear \
    php \
    php-cli \
    php-devel \
    php-gmp \
    php-fpm \
    php-mbstring \
    php-opcache \
    php-common \
    php-pdo \
    php-mysqlnd \
    php-gd \
    php-sodium \
    php-xml \
    php-process \
    php-zip \
    python3-pip \
    htop \
    ncurses \
    findutils \
    unzip

RUN yum install -y \
    php-devel \
    php-pear \
    gcc \
    make \
    tar \
    ImageMagick \
    ImageMagick-devel \
    ImageMagick-perl

RUN curl -L https://github.com/remicollet/imagick/archive/${IMAGICK_PHP83_FIX_COMMIT}.zip -o /tmp/imagick-issue-php83.zip  \
    && unzip /tmp/imagick-issue-php83.zip -d /tmp \
    && pecl install /tmp/imagick-${IMAGICK_PHP83_FIX_COMMIT}/package.xml \
    && echo "extension=imagick" > /etc/php.d/20-imagick.ini

# Remove dev package to keep the container small
RUN yum remove -y \
    php-devel \
    php-pear \
    gcc \
    make \
    ImageMagick-devel \
    ImageMagick-perl

@ghnp5
Copy link

ghnp5 commented Sep 17, 2024

This seems to be completely random.
Just need to keep running the build until it finally works...

@ilyahoilik
Copy link

I would not recommend you guys installing imagick/imagick@master version because you do not have 100% guarantee that new commits will not contain any issues and bugs.

Instead I may suggest you to install package not from branch but commit:

RUN install-php-extensions imagick/imagick@28f27044e435a2b203e32675e942eb8de620ee58

This approach guarantees that every your environment now and later will receive the same version of imagick and their new code will not break your deployment process.

https://github.com/mlocati/docker-php-extension-installer

@ghnp5
Copy link

ghnp5 commented Sep 24, 2024

Thanks @ilyahoilik - I didn't realize it installed from the repo's master/main like that.

However, looking at the "master" branch in imagick/imagick, the last commit was "last year", so it still doesn't make sense that it "randomly breaks".

Or am I missing something here? :)

@ilyahoilik
Copy link

ilyahoilik commented Sep 24, 2024

Or am I missing something here? :)

@ghnp5 ooops, I didn't look up to commit date, thought master branch updates regularly. My fault, sorry :) Anyway you can use my suggestion to install specific commit from any branch

@phoehnel
Copy link

Got a pipeline building this every week. For me the first successful run was on 16th of July using the following dockerfile.

FROM php:8.3-apache-bullseye
[...]

After an update of the php:8.3-apache-bullseye it stopped working for me again.
It now only works pinning the following version. Newer ones fail.

FROM php@sha256:7fb7a483bf2e0b4ea40a1918c6efc0574c049750dcb25c779e01c36af0778fe6

@lindelius
Copy link

lindelius commented Oct 21, 2024

Sorry for adding another bump to this, but can we please get a new version released so that we can finally install this extension via PECL for PHP 8.3? @Danack

@cardil
Copy link

cardil commented Nov 12, 2024

Complete workaround, that worked for me (with pinned versions):

FROM docker.io/library/php:8-fpm
ADD --chmod=0755 \
  https://github.com/mlocati/docker-php-extension-installer/releases/download/2.6.3/install-php-extensions \
  /usr/local/bin/
# TODO: Use latest released version, after https://github.com/Imagick/imagick/issues/640 is fixed
RUN install-php-extensions imagick/imagick@28f27044e435a2b203e32675e942eb8de620ee58

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

Successfully merging a pull request may close this issue.