aws-sam-cli: Unable to debug golang function using dlv from AWS documentation (`GLIBC_2.32' not found)
Description
Unable to debug golang applications using sam local invoke following the documentation provided by AWS. glibc used to build dlv doesn’t seem to be compat with the glibc in the docker image. sam build cannot build in a docker container so not sure what we are suppose to do about this.
Steps to reproduce
mkdir delve
GOARCH=amd64 GOOS=linux go build -o delve/dlv github.com/go-delve/delve/cmd/dlv
GOARCH=amd64 GOOS=linux go build -o dlv github.com/go-delve/delve/cmd/dlv
sam local invoke CrmEntityImportWorkerFunction -e unittestdata/crmentityimporter/events/110791.event --profile=tbrunomind -d 5986 --debugger-path delve/ --debug-args "-delveAPI=2" --debug"
Observed result
local invoke command is called
Collected default values for parameters: {'ENV': 'dev'}
...
...
...
Private data, just list of ENV vars and template values
..
...
19 resources found in the template
Found Serverless function with name='CrmEntityImportWorkerFunction' and CodeUri='./crm-entity-import-worker/'
....
...
....
(Private data, just a list of all functions)
...
...
...
...
Found one Lambda function with name 'CrmEntityImportWorkerFunction'
Invoking crm-entity-import-worker (go1.x)
Environment variables overrides data is standard format
Loading AWS credentials from session with profile 'mywork'
Resolving code path. Cwd=/home/tbruno/Projects/GolandProjects/lambda-crm-integration, CodeUri=./crm-entity-import-worker/
Resolved absolute path to code is /home/tbruno/Projects/GolandProjects/lambda-crm-integration/crm-entity-import-worker
Code /home/tbruno/Projects/GolandProjects/lambda-crm-integration/crm-entity-import-worker is not a zip/jar file
Image was not found.
Building image...Adding custom GO Bootstrap to support debugging
.........................
Failed to download image with name amazon/aws-sam-cli-emulation-image-go1.x:debug-1.6.2
Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:debug-1.6.2 image. Invoking with the already downloaded image.
Mounting /home/tbruno/Projects/GolandProjects/lambda-crm-integration/crm-entity-import-worker as /var/task:ro,delegated inside runtime container
Setting up SIGTERM interrupt handler
/tmp/lambci_debug_files/dlv: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/lambci_debug_files/dlv)
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: ArchLinux/Manjaro
sam --version
: SAM CLI, version 1.6.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (6 by maintainers)
This is now a much wider issue with most distributions moving to the newer 3.32 version of glibc. Confirmed on Fedora 35, Ubuntu 21.10 and latest Arch & Manjaro installs.
We really need Go apps to be built in containers that contain a compatible lambda glibc version. This issue is not limited to aws-sam-cli. Any Go binary built on one of these newer distribution builds using glibc 2.32 or later will fail to run on any docker image or linux distro that uses glibc 2.31 or earlier.
I am running into the same issue @ivan-pesenti is facing. Anyone get debugging working with vscode?
Hi all!
I was stuck at trying to debug locally an AWS lambda function with Go as runtime. Below are my machine details:
Below are the repro steps (I apologize if I’m too verbose but I’d like to give you my precise setup):
mkdir myLambda
cd myLambda
sam init
cd myLambda
make
I got this error:
Other attempts
I tried with this Makefile:
Same error as above
CGO_ENABLED
I compiled the program with this statement
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
After that I replaced the one below “.aws-ssm” folder but same error got.
Anyone can spot me in the right direction? If any details are missing I’ll provide.
Thanks!