Bref: gd library can not be loaded

Created on 13 Aug 2020  路  9Comments  路  Source: brefphp/bref

I followed all the steps of the documentation to enable gd and imagick but I get this error in the lambda:

## php7.4-fpm

NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I'm really tired of looking for a solution but I can't find a way, could someone help me?

//php.ini

extension=imagick
extension=gd
support

Most helpful comment

Ah I think I figured it out!

First, thanks @chekalsky, that repo was perfect and it did reproduce the problem.

After digging in the code, I realized that var_dump(get_loaded_extensions()) shows that gd is enabled, and gd functions are available. Since PHP 7.4 the --with-gd flag has been replaced by --enable-gd, and that builds gd and enables it.

That means that for PHP 7.3, we have to enable gd manually. From PHP 7.4 and up, we don't have to, it's automatically enabled!

All 9 comments

Sorry but we'll need much more information than that to help.

I got the same warning in bref:layer.php-74-fpm runtime and imagick operation failed with

`NoDecodeDelegateForThisImageFormat `' @ error/constitute.c/ReadImage/566`

CloudWatch Logs

[31-Aug-2020 20:54:53] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Provider

...
environment:
    BREF_BINARY_RESPONSES: 1
apiGateway:
    binaryMediaTypes:
    - '*/*'

php/conf.d/php.ini

extension=mongodb
extension=imagick
extension=gd

if you guys solved the issue, please help to fix this.

Hi, that's weird, I just tested:

extension=gd

And deployed a function:

<?php declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';

return function () {
    var_dump(get_loaded_extensions());
};

It shows that gd is loaded, but I get no warning at all.

Can you make sure that you run the latest Bref version? Or maybe imagick is causing issues when enabled at the same time as gd?

@mnapoli I have the same issue.

My php/conf.d/php.ini contains only extension=gd. I use ${bref:layer.php-74-fpm} layer.

Error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Which information do you need to proceed?

P.S. It's the same with imagick:

PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick' (tried: /opt/bref/lib/php/extensions/no-debug-zts-20190902/imagick (/opt/bref/lib/php/extensions/no-debug-zts-20190902/imagick: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-zts-20190902/imagick.so (libMagickWand.so.5: cannot open shared object file: No such file or directory)) in Unknown on line 0

P.P.S. file_exists('/opt/bref/lib/php/extensions/no-debug-zts-20190902/imagick.so') returns true 馃

@chekalsky for imagick, check out #743 as we are having problems with it because of changes in the AWS environment.

For gd I tested 20 days ago and couldn't find any issue, could you try creating a smallest repository possible that can reproduce this and share it? That way I have something to investigate.

Thanks!

@mnapoli it was easier than I thought :) maybe region is the source of the issue?

https://github.com/chekalsky/bref-gd-issue

I can confirm I get this error with the latest serverless:

PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so (/opt/bref/lib/php/extensions/no-debug-zts-20190902/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

@chekalsky I cannot access the repository, is it private?

@mnapoli oops. fixed :)

Ah I think I figured it out!

First, thanks @chekalsky, that repo was perfect and it did reproduce the problem.

After digging in the code, I realized that var_dump(get_loaded_extensions()) shows that gd is enabled, and gd functions are available. Since PHP 7.4 the --with-gd flag has been replaced by --enable-gd, and that builds gd and enables it.

That means that for PHP 7.3, we have to enable gd manually. From PHP 7.4 and up, we don't have to, it's automatically enabled!

Was this page helpful?
0 / 5 - 0 ratings