Skip to content

File too short on shared library libpcre2-8.so.0 #21

Open

Description

@fongie

Hi!

I am trying to run git with this layer in a SAM lambda build.

Template snippet:

LambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/
      Handler: app.lambda_handler
      Runtime: python3.7
      Layers:
        - arn:aws:lambda:eu-west-1:553035198032:layer:git:10

Code snippet:

subprocess.call(['git', 'init', '/tmp/Apps/CDN/'])

or

os.system('cd /tmp/Apps/CDN && git init')

All attempts fail with git: error while loading shared libraries: /opt/lib/libpcre2-8.so.0: file too short

I also tried using the second version of the layer (despite py3.7 not being listed for it) instead, but that also fail with the same error.

Any ideas how this can be solved?

Activity

  1. cvanes commented on Mar 11, 2020

    @cvanes

    Same issue here when running locally using sam-cli. Is this layer compatible with sam-cli?

  2. mhart commented on Mar 11, 2020

    @mhart
    Member

    @cvanes I don't think sam-cli knows how to deal with symlinks properly (unlike Lambda itself). There are a bunch of issues open about it on that repo I believe

    @fongie were you getting this error in a production Lambda, or just running sam locally?

  3. mhart commented on Mar 11, 2020

    @mhart
    Member

    You can get it running on sam cli, but you'll need to unzip the layer zip manually yourself and change your Layers configuration unfortunately. You can see a similar example of this over here: https://github.com/lambci/yumda#full-example-with-aws-sam

    There's a PR open at sam-cli to fix the symlink issue, but it doesn't look like it's had much love recently: aws/aws-sam-cli#1482

  4. fongie commented on Mar 11, 2020

    @fongie
    Author

    Thanks! That explains it, and the example should get me started. I got the error running locally and the code never made it to production yet because of it. Is there reason to believe it would work if I pushed it to AWS?

  5. mhart commented on Mar 11, 2020

    @mhart
    Member

    Yep, absolutely – it's purely a bug in sam cli. If you use docker-lambda directly you should be able to get it to work locally (you'll just need to mount the layer directory manually)

  6. ryanblock commented on Sep 22, 2022

    @ryanblock

    Unrelated to sam-cli, this issue was resolved for me by ensuring git, if run within a child process within Lambda, is provided LD_LIBRARY_PATH (and also I believe PATH) env vars from the host Lambda process. Fwiw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions