question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS Lambda Fails On Require

See original GitHub issue

Hi,

I apologize in advance if I’m missing something simple, but I’ve read through a bunch of the issues that were similar to this one, and the solutions did not fix my issue. I am using sharp in an AWS Lambda, which I am packing up on a Mac. Whenever the Lambda runs, I get this error when the Lambda attempts to require(‘sharp’)

Something went wrong installing the "sharp" module

libvips-cpp.so.42: cannot open shared object file: No such file or directory

- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues

I have tried running the npm install with all the options mentioned in the installation guide, and using the docker run command. Both result in this same error message. I am able to use Sharp locally on my Mac with a docker run command of docker run -v "$PWD":/var/task lambci/lambda:build-nodejs10.x node index2.js where index2.js is just a little test file. I am on macOS 10.14.6 and using node10.x on the Lambda.


Did you see the documentation relating to installation?

Yes, I have followed the instructions for setting up sharp for a Lambda function with the npm install and zip occuring on a Mac

Have you ensured the platform and version of Node.js used for npm install is the same as the platform and version of Node.js used at runtime?

Yes, I tried both options available in the installation instructions

If you’re (mis)using sudo npm install have you tried with the sudo npm install --unsafe-perm flag?

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?

I don’t see any errors on the npm install

What is the output of running npx envinfo --binaries --languages --system --utilities?

Would this be useful to run in the AWS Lambda?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DeanBDeancommented, Sep 25, 2019

So I finally got to the bottom of it, and it turns out it was unrelated to your library. So I apologize for using up your time, and appreciate you helping me get to the bottom of it. I was using terraform to zip the Lambda contents, but the archive_file provider from terraform has an old, nasty bug where it does not handle symlinks correctly.

https://github.com/terraform-providers/terraform-provider-archive/issues/6#issuecomment-321376294

For anyone in the future who runs into this as a problem, I used the above to workaround terraform’s inability to zip files with symlinks

0reactions
lovellcommented, Sep 25, 2019

Glad to hear you got it working.

If you’re able, I’m sure users of terraform-provider-archive would welcome a PR to either fix this problem or a PR to clearly document this limitation in the currently-blank “Fill in for each provider” section of its README.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda function errors in Node.js
This page describes how to view Lambda function invocation errors for the Node.js runtime using the Lambda console and the AWS CLI.
Read more >
Error handling and automatic retries in AWS Lambda
When you invoke a function, two types of error can occur. Invocation errors occur when the invocation request is rejected before your function...
Read more >
How do I troubleshoot Lambda function failures? - AWS
To troubleshoot Lambda function failures, first determine what's causing the error by using one or more of the AWS services and features ......
Read more >
Troubleshoot execution issues in Lambda - AWS Documentation
Function execution errors can be caused by issues with your code, function configuration, downstream resources, or permissions. If you invoke your function ...
Read more >
AWS Lambda function errors in Python
This page describes how to view Lambda function invocation errors for the Python runtime using the Lambda console and the AWS CLI.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found