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.

M1 Mac (Apple Silicon): Debugging SAM .NET Function not working

See original GitHub issue

When debugging the simple SAM .NET 3.1 or 2.1 hello world function you get a pop up error “No process with the specified name is currently running”. And a timeout error: 2021-03-13 17:19:51 [ERROR]: Unable to attach Debugger. Check AWS Toolkit logs. If it took longer than expected to start, you can still attach.

image

Steps to reproduce

  1. run sam init
$ sam init
Which template source would you like to use?
	1 - AWS Quick Start Templates
	2 - Custom Template Location
Choice: 1
What package type would you like to use?
	1 - Zip (artifact is a zip uploaded to S3)
	2 - Image (artifact is an image uploaded to an ECR image repository)
Package type: 1

Which runtime would you like to use?
	1 - nodejs14.x
	2 - python3.8
	3 - ruby2.7
	4 - go1.x
	5 - java11
	6 - dotnetcore3.1
	7 - nodejs12.x
	8 - nodejs10.x
	9 - python3.7
	10 - python3.6
	11 - python2.7
	12 - ruby2.5
	13 - java8.al2
	14 - java8
	15 - dotnetcore2.1
Runtime: 6

Project name [sam-app]:

Cloning app templates from https://github.com/aws/aws-sam-cli-app-templates

AWS quick start application templates:
	1 - Hello World Example
	2 - Step Functions Sample App (Stock Trader)
Template selection: 1

    -----------------------
    Generating application:
    -----------------------
    Name: sam-app
    Runtime: dotnetcore3.1
    Dependency Manager: cli-package
    Application Template: hello-world
    Output Directory: .

    Next steps can be found in the README file at ./sam-app/README.md
  1. cd sam-app
  2. code .
  3. Create debug configuration for src/HelloWorld/Function.cs
  4. Click run and debug
  5. Choose sam-app:HelloWorldFunction configuration and press green play button
  6. Wait for config and docker container to start
  7. Error pops up.
  8. however container is running:
 sam-app docker ps
CONTAINER ID   IMAGE                                                           COMMAND                  CREATED              STATUS              PORTS                                                NAMES
07cf7754be6d   amazon/aws-sam-cli-emulation-image-dotnetcore3.1:rapid-1.20.0   "/var/rapid/aws-lamb…"   About a minute ago   Up About a minute   127.0.0.1:5860->5860/tcp, 127.0.0.1:6046->8080/tcp   silly_noether
  1. Can connect to container fine and ls:
sam-app docker exec -i $(docker ps -q -f publish=5860) sh
ls
Amazon.Lambda.APIGatewayEvents.dll
Amazon.Lambda.Core.dll
Amazon.Lambda.Serialization.Json.dll
HelloWorld.deps.json
HelloWorld.dll
HelloWorld.pdb
HelloWorld.runtimeconfig.json
Newtonsoft.Json.dll

Expected behavior

I expect a debug session to start successfully which i confirmed works fine on an Intel Mac.

Screenshots

Desktop (please complete the following information):

  • OS:
  • Visual Studio Code Version: Version: 1.54.2 Commit: fd6f3bce6709b121a895d042d343d71f317d74e7 Date: 2021-03-11T00:56:09.783Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Darwin x64 20.3.0
  • AWS Toolkit Version: 1.20.0 Also running latest docker M1 pre-release Docker Desktop preview 3.1.0

Additional context Tried both x64 and arm64 modes for vs code. Same result. I am wondering if it is related to: https://github.com/OmniSharp/omnisharp-vscode/issues/4277

logs.txt Extra logging debug:

Starting: "sh" -c "docker exec -i $(docker ps -q -f publish=5860) /tmp/lambci_debug_files/vsdbg --interpreter=vscode"
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
-> (C) {"command":"attach","arguments":{"type":"coreclr","request":"attach","name":"sam-app:HelloWorldFunction","logging":{"engineLogging":false,"trace":true},"invokeTarget":{"target":"template","templatePath":"/Users/matt/dev/github/sam-app/template.yaml","logicalId":"HelloWorldFunction"},"lambda":{"payload":{},"environmentVariables":{},"timeoutSec":10},"__configurationTarget":5,"codeRoot":"/Users/matt/dev/github/sam-app","workspaceFolder":{"uri":{"$mid":1,"fsPath":"/Users/matt/dev/github/sam-app","external":"file:///Users/matt/dev/github/sam-app","path":"/Users/matt/dev/github/sam-app","scheme":"file"},"name":"sam-app","index":0},"runtime":"dotnetcore3.1","runtimeFamily":3,"handlerName":"HelloWorld::HelloWorld.Function::FunctionHandler","documentUri":{"$mid":1,"fsPath":"/Users/matt/dev/github/sam-app/.vscode/launch.json","external":"file:///Users/matt/dev/github/sam-app/.vscode/launch.json","path":"/Users/matt/dev/github/sam-app/.vscode/launch.json","scheme":"file"},"templatePath":"/tmp/aws-toolkit-vscode/vsctk47aQPw/output/template.yaml","eventPayloadFile":"/tmp/aws-toolkit-vscode/vsctk47aQPw/event.json","envFile":"/tmp/aws-toolkit-vscode/vsctk47aQPw/env-vars.json","debugPort":5860,"useIkpdb":false,"baseBuildDir":"/tmp/aws-toolkit-vscode/vsctk47aQPw","debuggerPath":"/Users/matt/dev/github/sam-app/src/HelloWorld/.vsdbg","processName":"dotnet","pipeTransport":{"pipeProgram":"sh","pipeArgs":["-c","docker exec -i $(docker ps -q -f publish=5860) ${debuggerCommand}"],"debuggerPath":"/tmp/lambci_debug_files/vsdbg","pipeCwd":"/Users/matt/dev/github/sam-app/src/HelloWorld"},"__sessionId":"8196f443-def6-4632-8ed6-909792d9890b"},"type":"request","seq":2}
<- (E) {"seq":3,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/AttachFailed","data":{"VS.Diagnostics.Debugger.vsdbg.AdapterId":"coreclr","VS.Diagnostics.Debugger.vsdbg.ErrorCode":2001,"VS.Diagnostics.Debugger.vsdbg.Distribution.Name":"bc4f1536","VS.Diagnostics.Debugger.vsdbg.Distribution.Version":"2","VS.Diagnostics.Debugger.vsdbg.OSFamily":"Linux","VS.Diagnostics.Debugger.vsdbg.Version":"16.9.20122.2 commit:c3006f59a1d3a160c9fc06f5e2e14402522190e3"}}}
<- (R) {"seq":4,"type":"response","request_seq":2,"success":false,"command":"attach","message":"No process with the specified name is currently running."}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
CasperM15commented, Oct 20, 2022

This is blocked on aws/aws-sam-cli#3283 .

Workaround via aws/aws-sam-cli#3389 (comment) is to specify arm64 architecture in template.yaml :

Architectures:
   - arm64

If we specify arm64 architecture in template.yaml then debugger does not work because vsdbg debugger does not currently support the arm64 architecture and the function will run locally without debug.

2reactions
mattgillardcommented, Mar 15, 2021

ok … i understand now. The mac docker vm is arm64. Which runs the x86 emulation - which maps to your hypothesis.

docker run -it --rm --privileged --pid=host justincormack/nsenter1
Unable to find image 'justincormack/nsenter1:latest' locally
latest: Pulling from justincormack/nsenter1
726619a9fa8c: Pull complete
Digest: sha256:e876f694a4cb6ff9e6861197ea3680fe2e3c5ab773a1e37ca1f13171f7f5798e
Status: Downloaded newer image for justincormack/nsenter1:latest
/ #
/ # find / -name qemu-x86_64
/var/lib/mount-docker-cache/entries/services.tar/d083ad549ba5be0ab0cb2ecfab00891427b9e55c8383277a12bb0fca18916a35/containers/services/binfmt/rootfs/usr/bin/qemu-x86_64
/var/lib/mount-docker-cache/entries/services.tar/d083ad549ba5be0ab0cb2ecfab00891427b9e55c8383277a12bb0fca18916a35/containers/services/binfmt/lower/usr/bin/qemu-x86_64
/proc/sys/fs/binfmt_misc/qemu-x86_64
/containers/services/binfmt/rootfs/usr/bin/qemu-x86_64
/containers/services/binfmt/lower/usr/bin/qemu-x86_64
/ # uname -a
Linux docker-desktop 4.19.121-linuxkit #1 SMP PREEMPT Thu Jan 21 15:45:22 UTC 2021 aarch64 Linux
Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS SAM Python debug on Mac M1 (Apple Silicon)
While trying to build images in M1 Mac I always have problems. I'm currently trying to debug the Python Lambda function and got...
Read more >
Installing the AWS SAM CLI - AWS Serverless Application Model
This section describes how to install the AWS SAM CLI on macOS, Windows, and Linux.
Read more >
Revive or restore a Mac with Apple silicon using Apple ...
In rare circumstances, Apple computers become unresponsive and the chip's firmware must be revived or restored.
Read more >
Apple Silicon M1, AWS SAM-CLI, Docker, MySql, and .netcore ...
The question everyone is asking!, Can I develop a .netcore 3.1 serverless application on a Mac M1 using AWS Amplify, SAM-CLI, MySql and ......
Read more >
ARM64 Support - LocalStack Docs
Apple Silicon / Apple M1 ... If you are experiencing issues with the ARM64 image (and after you created an issue to make...
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