-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug: Unable to run sam local invoke on Apple Silicon #7061
Comments
Thanks for reporting this issue. Can you try changing your runtime to We've merged a fix to align with the change above, however it is not been released yet. If you confirm that changing to newer runtime works, we can assume that new SAM CLI release should fix the issue. |
Thanks for responding @mndeveci. I did try it with Logs:
|
Thanks for confirmation! Can you also confirm what happens when you deploy this function? As far as we can see, when this function is deployed it works as expected, however running locally fails with the error that you mentioned above. From our side we validated following scenarios;
|
@nataizya we've tried with a Docker alternative, and it worked without issues. I believe this is coming from Docker Desktop's Apple Silicon distribution since it also works on Intel machines. |
I suspect that the deployment will work as well though I havent tested that. Can you elaborate on what exactly you mean by trying it with a Docker alternative? What commands would I be using to test that? |
Before going further down the list, you may try to uninstall/remove Docker Desktop completely and install it from their official installers, to see if it is going to fix your problem (I've seen that sometimes a clean installation fixes their issues). I can't open an issue on their repository since they are asking more details which I can't provide since I am using an Intel Macbook. If you can, I will recommend creating an issue in this repository here; https://github.com/docker/for-mac/issues
There are alternative tools which can replace Docker Desktop, and they provide similar experience to use containers on your machine. Some of those are podman or rancher. |
Local invocation works for me after change to |
Setting the architecture to |
Please keep in mind that, if you change |
Noted. I will try and make use of podman or rancher. But for now I can at least test the function locally by temporarily switching to |
As another workaround (which might be better since this doesn't require architecture change), you can also build Rust x86 function with !!! Please don't use |
I think we found the root cause (thanks to @lucashuy). There was a change in However the reason for the change above was to make it more optimized for the target lambda runtime. So this code works when it is deployed (as intended) however when it is tried to be emulated on Apple Silicon machines, it doesn't work (possible) missing support from Docker Desktop. We don't want to change default target since this was selected due to optimizations, for now we would ask customers to use workaround to build with |
Thanks @mndeveci . I can confirm that using |
Thanks all for working with us on this issue. Just to sum up for future folks popping into this issue: SAM CLI builds Rust Functions for "release mode", meaning that specific architecture level optimizations are applied when building the binary. Unfortunately, these optimizations do not work when invoking them in an x86 container, on an arm64 Mac. WorkaroundBefore building the Lambda function, set the Please note that this is only recommended when building and testing locally. We advise customers to switch back to a release build by unsetting or removing the Whats nextOur team is going to prioritize adding a disclaimer message saying the essentially the same thing inside of |
Description:
I am trying to setup a rust lambda function and to test, I am running
sam local invoke
. This fails with:The same command works fine on an Intel Mac.
Steps to reproduce:
On an Apple Silicon (e.g. M2) machine, setup a Rust lambda:
sam init
AWS Quick Start Templates
Hello World Example
rust (provided.al2)
N
for the following options.sam build
<--- this succeedssam local invoke
Observed result:
Expected result:
Successfully run the
sam local invoke
command and run the lambda function.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
MacOS 14.4.1 (23E224)
sam --version
:SAM CLI, version 1.116.0
Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: