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

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

Open
fongie opened this issue Mar 5, 2020 · 6 comments
Open

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

fongie opened this issue Mar 5, 2020 · 6 comments

Comments

@fongie
Copy link

fongie commented Mar 5, 2020

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?

@cvanes
Copy link

cvanes commented Mar 11, 2020

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

@mhart
Copy link
Member

mhart commented Mar 11, 2020

@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?

@mhart
Copy link
Member

mhart commented Mar 11, 2020

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

@fongie
Copy link
Author

fongie commented Mar 11, 2020

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?

@mhart
Copy link
Member

mhart commented Mar 11, 2020

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)

@ryanblock
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants