[英]/lib64/libc.so.6: version `GLIBC_2.32' not found
I'm building the lambda on Ubuntu with the basic example.我正在使用基本示例在 Ubuntu 上构建 lambda。 It builds without any errors but if I upload and test it on aws in crashes with:
它构建时没有任何错误,但如果我在 aws 上上传并测试它,它会崩溃:
{
"errorMessage": "RequestId: 7f4d0aca-125c-4032-98dd-9ff387e5252b Error: Runtime exited with error: exit status 1",
"errorType": "Runtime.ExitError"
}
The log output is:日志output是:
START
RequestId: 7f4d0aca-125c-4032-98dd-9ff387e5252b
Version: $LATEST.~.jwtauthorizeraws.jwtauthorizerawsapplication: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./~.jwtauthorizerawsapplication)
END
RequestId: 7f4d0aca-125c-4032-98dd-9ff387e5252b
REPORT
RequestId: 7f4d0aca-125c-4032-98dd-9ff387e5252b
Duration: 56.02 ms
Billed Duration: 57 ms
Memory Size: 128 MB
Max Memory Used: 7 MB
RequestId: 7f4d0aca-125c-4032-98dd-9ff387e5252b
Error: Runtime exited with error: exit status 1
Runtime.ExitError
It probably means that the glibc
version used to build the executable is different than the docker environment is using.这可能意味着用于构建可执行文件的
glibc
版本与 docker 环境使用的不同。
So, check the build environment ldd --version
will reveal the glibc version.因此,检查构建环境
ldd --version
将显示 glibc 版本。
Now, in your docker container ( docker run -ti --entrypoint=/bin/bash dockerimage:tag
) type the same ldd
command.现在,在您的 docker 容器 (
docker run -ti --entrypoint=/bin/bash dockerimage:tag
) 中键入相同的ldd
命令。 You'll probably see that the versions are different.您可能会看到版本不同。 So, update either the build environment to use the same version as the docker environment or vice-versa.
因此,更新构建环境以使用与 docker 环境相同的版本,反之亦然。
The best way to avoid this is to use the runtime environment to build your native executable: this way the glibc
version will always match.避免这种情况的最佳方法是使用运行时环境来构建您的本机可执行文件:这样
glibc
版本将始终匹配。
FWIW, in Quarkus, we have a feature called in-container build, which allows to create your native image inside a container that is compatible with the runtime images we use. FWIW,在 Quarkus 中,我们有一个称为容器内构建的功能,它允许在与我们使用的运行时图像兼容的容器内创建您的原生图像。
Using -Dquarkus.native.container-build=true
makes it happen.使用
-Dquarkus.native.container-build=true
可以实现。
Not saying you should migrate to Quarkus but if you want to build native images, you really need to build them in an environment compatible with your runtime environment so you will end up having to build in a container.并不是说你应该迁移到 Quarkus,但如果你想构建原生图像,你真的需要在与你的运行时环境兼容的环境中构建它们,所以你最终将不得不在容器中构建。
I recently ran into this issue.我最近遇到了这个问题。
Build your project with CGO_ENABLED=0
may be enough to fix your issue :使用
CGO_ENABLED=0
构建项目可能足以解决您的问题:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go
If you are using sam
, there is a --use-container
flag, however this may not work for golang projects如果您使用的是
sam
,则有一个--use-container
标志,但这可能不适用于 golang 项目
To make sam build
use a custom build command, ie run the go build
command above, you can set the BuildMethod
to makefile
and create a Makefile
with a target with the name build-<YourFunctionName>
.要使
sam build
使用自定义构建命令,即运行上面的go build
命令,您可以将BuildMethod
设置为makefile
并创建一个Makefile
,其目标名称为build-<YourFunctionName>
。
HealthCheckFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: makefile
Properties:
CodeUri: .
Handler: healthcheck
FunctionName: !Sub "healthcheck_${Env}"
Runtime: go1.x
Architectures:
- x86_64
Events:
...
Then the Makefile
would have:那么
Makefile
将具有:
build-HealthCheckFunction:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o healthcheck lambda/healthcheck/healthcheck.go
mv healthcheck $(ARTIFACTS_DIR)
More details here on what I had to do to get this fixed in my project: https://www.gaunt.dev/blog/2022/glibc-error-with-aws-sam-and-go/有关我必须做些什么才能在我的项目中修复此问题的更多详细信息: https://www.gaunt.dev/blog/2022/glibc-error-with-aws-sam-and-go/
the environment you are executing the seems doesn't provide a Glibc version in version 2.32.您正在执行的环境似乎没有在 2.32 版中提供 Glibc 版本。
This can have several problems: the version of your the Lambda env is older, or it doesn't provide an GlibC at all (which can be the case).这可能有几个问题:您的 Lambda env 的版本较旧,或者它根本不提供 GlibC(可能是这种情况)。
if you application would be pure java (without creating an native app via graal) it would run since the java app itself doesn't depend a version of GLibC, the requirment comes from the native app.如果您的应用程序是纯 java(不通过 graal 创建本机应用程序),它将运行,因为 java 应用程序本身不依赖于 GLibC 版本,该要求来自本机应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.