AWS Lambda: fork/exec /var/task/demo: exec format error: PathError null

AWS Lambda format error

2 min read | by Jordi Prats

Executing a lambda function we might find that if fails with the following error:

2023-02-04T21:15:33.723+01:00 START RequestId: 7cb12d0d-1e8c-4a8d-485a-0f5dced9a545 Version: $LATEST
2023-02-04T21:15:33.723+01:00 fork/exec /var/task/demo: exec format error: PathError null
2023-02-04T21:15:33.724+01:00 END RequestId: 7cb12d0d-1e8c-4a8d-485a-0f5dced9a545

The exec format error: PathError null is an error that can occur when you try to run a binary file in a Lambda function that is built for a different operating system. This error can be caused by uploading the binary file in the incorrect format or by using a binary that is not compatible with the architecture we have defined for the lambda function (Architecture):

lambda runtime settings

Typically, this happens when we are uploading a binary that you have built locally that doesn't match the architecture that it is going to use on the cloud. Besides the architecture we'll have to match the platform as well. For lambda functions it needs to be Linux.

Depending on the runtime we choose we'll need to follow different steps to cross-compile (or install certain applications to do it). For Go lang, won't need much, since the go command can cross-compile natively.


Posted on 13/02/2023

Categories