extra-php-extensions icon indicating copy to clipboard operation
extra-php-extensions copied to clipboard

PHP Startup: Unable to load dynamic library 'gnupg.so' (tried: /opt/bref/extensions/gnupg.so (libgpgme.so.11: cannot open shared object file: No such file or directory)

Open mdschertz opened this issue 2 years ago • 3 comments

When using the gnupg-php-82 this error message appears in the Cloudwatch logs for the Lambda function.

mdschertz avatar May 10 '23 16:05 mdschertz

We will need more details to help.

mnapoli avatar May 10 '23 20:05 mnapoli

I've been digging into it and I think I have found the issue although not the solution yet. The problem is that libgpgme.so.11 and libassuan.so.0 aren't in any of the library paths. I created a layer that added them which appears to work but then has a libc version mismatch error.

It's easy to replicate using this serverless.yml:

service: PGP-Encrypt

provider: name: aws region: us-east-1

plugins: - ./vendor/bref/bref - ./vendor/bref/extra-php-extensions

functions: Encrypt: handler: test.php layers: - ${bref-extra:gnupg-php-81} description: '' runtime: php-81-fpm timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) events: - httpApi: '*'

package: patterns: - '!node_modules/' - '!tests/'

And the test.php file from the repo in the gnupg layer

mdschertz avatar May 12 '23 14:05 mdschertz

Similar issue in PHP 8.3. A warning instead of initial error was reported.

Warning: PHP Startup: Unable to load dynamic library 'gnupg.so' (tried: /opt/bref/extensions/gnupg.so (libgpgme.so.11: cannot open shared object file: No such file or directory), /opt/bref/extensions/gnupg.so.so (/opt/bref/extensions/gnupg.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Here are my project files.

composer.json:

{
    "require": {
        "bref/bref": "^2.1.12",
        "bref/extra-php-extensions": "^1.4.0"
    }
}

serverless.yml

service: bref-demo

provider:
    name: aws
    region: us-east-1

plugins:
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions

functions:
    hello:
        handler: index.php
        description: ''
        runtime: php-83
        layers:
            - ${bref-extra:gnupg-php-83}

# Exclude files from deployment
package:
    patterns:
        - '!tests/**'

index.php:

<?php declare(strict_types=1);

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

return function ($event) {
    phpinfo();
    return 'Hello ' . ($event['name'] ?? 'world');
};

SyuTingSong avatar Jan 25 '24 10:01 SyuTingSong

Fixed in the latest release.

mnapoli avatar Aug 26 '24 08:08 mnapoli