aws-samples / aws-lambda-elixir-runtime

Example implementation of a custom runtime for running Elixir on AWS Lambda.
MIT No Attribution
127 stars 32 forks source link

cannot execute binary file #11

Open benkeil opened 2 years ago

benkeil commented 2 years ago

Does anyone has a running example?

Invoking Elixir.Playground:playground_handler (provided)
Decompressing /Users/ben/development/github.com/benkeil/elixir_lambda/lambda.zip
Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided:rapid-1.55.0-x86_64.

Mounting /private/var/folders/mv/ntn0l4dx77d5hhqtwgmcrg0h0000gn/T/tmpskuus7j6 as /var/task:ro,delegated inside runtime container
START RequestId: 9216089f-f446-4509-a326-07f73253b4be Version: $LATEST
++ dirname /var/task/bootstrap
+ BASE=/var/task
+ EXE=/var/task/bin/playground
+ HOME=/tmp
+ export HOME
+ export RELEASE_READ_ONLY=true
+ RELEASE_READ_ONLY=true
+ export LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/var/task/lib/elixir_runtime-0.1.0/priv
+ LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/var/task/lib/elixir_runtime-0.1.0/priv
+ /var/task/bin/playground start
/var/task/releases/0.1.0/../../erts-13.0.4/bin/erl: line 12: /var/task/erts-13.0.4/bin/erlexec: cannot execute binary file
/var/task/releases/0.1.0/../../erts-13.0.4/bin/erl: line 12: /var/task/erts-13.0.4/bin/erlexec: Success
10 Sep 2022 22:00:38,419 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 126 InvokeID=
++ dirname /var/task/bootstrap
+ BASE=/var/task
+ EXE=/var/task/bin/playground
+ HOME=/tmp
+ export HOME
+ export RELEASE_READ_ONLY=true
+ RELEASE_READ_ONLY=true
+ export LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/var/task/lib/elixir_runtime-0.1.0/priv
+ LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/var/task/lib/elixir_runtime-0.1.0/priv
+ /var/task/bin/playground start
/var/task/releases/0.1.0/../../erts-13.0.4/bin/erl: line 12: /var/task/erts-13.0.4/bin/erlexec: cannot execute binary file
/var/task/releases/0.1.0/../../erts-13.0.4/bin/erl: line 12: /var/task/erts-13.0.4/bin/erlexec: Success
END RequestId: 094fd9fe-e205-4ad9-9751-fb087d2098f5
REPORT RequestId: 094fd9fe-e205-4ad9-9751-fb087d2098f5  Init Duration: 1.05 ms  Duration: 1271.60 ms    Billed Duration: 1272 ms    Memory Size: 256 MB Max Memory Used: 256 MB
carstenpiepel commented 1 year ago

I ran into the same thing. It's because the version of erlexec that is included with your release does match the operating system, Amazon Linux 2 if you are building for Lambda. In my case, I thought I had this covered by building on the latest Amazon Linux 2 docker container using Docker Desktop for MacOS but there is a problem with the current Docker Engine version for MacOS that generates an ERTS that is somehow incompatible with the Amazon Linux 2 version used by Lambda.

See Error compiling elixir 1.15.2 on amazon linux with otp-26.0.2] and Erlang/OTP 25 JIT on AArch64 fails in user mode emulation.

As a workaround, I recommend you spin up an Amazon Linux 2 EC2 instance and build there. Of course, that has it's own challenges because using any recent version of OTP and Elixir will require building it from scratch.