Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libffi-d78936b1.so.6.0.4: cannot open shared object file Error on AWS Lambda function

I am trying to deploy a python Lambda package with watson_developer_cloud sdk. Cryptography is one of many dependencies this package have. I have build this package on Linux machine. My package includes .libffi-d78936b1.so.6.0.4 hidden file too. But it is still not accessible to my lambda function. I am still getting 'libffi-d78936b1.so.6.0.4: cannot open shared object file' Error. I have built my packages on Vagrant server, using instructions from here: https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html#with-s3-example-deployment-pkg-python

Exact error:

Unable to import module 'test_translation': libffi-d78936b1.so.6.0.4: cannot open shared object file: No such file or directory

On a note, as explained in this solution, I have already created my package using zip -r9 $DIR/lambda_function.zip . instead of *. But it is still not working for me.

Any direction is highly appreciable.

like image 913
sheenu85 Avatar asked Sep 09 '26 05:09

sheenu85


2 Answers

The libffi-d78936b1.so.6.0.4 is in a hidden folder named .libs_cffi_backend.

So to add this hidden folder in your lambda zip, you should do something like:

zip -r ../lambda_function.zip * .[^.]*

That will create a zip file in the directory above with the name lambda_function.zip, containing all files in the current directory (first *) and every thing starting with .* but not ..* ([^.])

like image 50
Frank Zomerdijk Avatar answered Sep 10 '26 19:09

Frank Zomerdijk


In a situation like this, I would invest some time setting up a local SAM environment so you can:

1 - Debug your Lambda

2 - Check what is being packaged and the files hierarchy

https://docs.aws.amazon.com/lambda/latest/dg/test-sam-cli.html

Alternatively you can remove this import and instrument your lambda function to print some of the files and directories it "sees".

I strongly recommend you giving SAM a try though, since it will make not only this debugging way easier but any further test you need to perform down the road. Lambdas are tricky to debug.

like image 32
Marcello Grechi Lins Avatar answered Sep 10 '26 19:09

Marcello Grechi Lins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!