aws / aws/aws-sam-cli

Bug: Cannot attach to debugger for Apple ARM-Based Chip in VS Code

Open
#7,828 4 comments 0 reactions 0 assignees View on GitHub
stage/needs-investigation
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
When attempting to attach a debugger to a locally running AWS Lambda function using the SAM CLI on an Apple ARM-based chip (e.g., M1/M2), the debugger keep hanging and never attached. My guess is potentially due to compatibility issues between the debugger, SAM CLI, and Docker on the ARM architecture.

### Steps to reproduce:
1. Create new directory
```
mkdir -p ~/.vsdbg
```
2. Use Docker to download and install vsdbg for the AWS Lambda runtime container with .NET 6 and copy it to local machine
```
docker run --rm --mount type=bind,src=~/.vsdbg,dst=/vsdbg --entrypoint bash lambci/lambda:dotnet6.0 -c "curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg"
```
3. Build SAM
```
sam build
```
4. SAM local start api
```
sam local start-api --port 1111 --skip-pull-image --debug-port 5858 --debugger-path ~/.vsdbg --warm-containers EAGER
```
5. Start launch.json
```
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Docker Attach",
"type": "coreclr",
"request": "attach",
"processId": "1",

"pipeTransport": {
"pipeProgram": "sh",
"pipeArgs": [
"-c",
"docker exec -i $(docker ps -q -f publish=5858) ${debuggerCommand}"
],
"debuggerPath": "/tmp/lambci_debug_files/vsdbg",
"pipeCwd": "${workspaceFolder}",
},
"sourceFileMap": {
"/var/task": "${workspaceFolder}"
}
}
]
}
```
*I attempted to try both run the launch.json file before and after hitting the endpoint to see if it makes any different.*

### Observed result:
No breakpoint were hit. the debugger keep hanging and never actually attached.

### Expected result:
It will actually hit the breakpoints.

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: MacOS Apple M3
2. `sam --version`: 1.132
3. Lambda Runtime: dotnet6

```
{
"version": "1.132.0",
"system": {
"python": "3.13.1",
"os": "macOS-15.2-arm64-arm-64bit-Mach-O"
},
"additional_dependencies": {
"docker_engine": "27.3.1",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.