aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.58k stars 479 forks source link

Linux libraries not being found in the DotNet 8 Managed Runtime #1724

Closed genifycom closed 7 months ago

genifycom commented 7 months ago

Describe the bug

We have a dotnet 6 Lambda AWS Application that uses QuestPDF (and hence SkiaSharp and HarfbuzzSharp) libraries. They include the Linux libraries required to run in Lambda and have been in production for a while.

On upgrading to dotnet 8, the Managed runtime seems to be unable to find them:

` ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:

libfontconfig.so.1: cannot open shared object file: No such file or directory /var/lang/bin/shared/Microsoft.NETCore.App/8.0.3/libSkiaSharp.so: cannot open shared object file: No such file or directory /var/task/liblibSkiaSharp.so: cannot open shared object file: No such file or directory /var/lang/bin/shared/Microsoft.NETCore.App/8.0.3/liblibSkiaSharp.so: cannot open shared object file: No such file or directory

/var/task/libSkiaSharp: cannot open shared object file: No such file or directory /var/lang/bin/shared/Microsoft.NETCore.App/8.0.3/libSkiaSharp: cannot open shared object file: No such file or directory /var/task/liblibSkiaSharp: cannot open shared object file: No such file or directory /var/lang/bin/shared/Microsoft.NETCore.App/8.0.3/liblibSkiaSharp: cannot open shared object file: No such file or directory`

We have confirmed that the libraries libSkiaSharp.so and libHarfbuzzSharp.so are in the Zip file sent to AWS Lambda (from Visual Studio 2022 AWS Toolkit).

It seems like there might be an issue with the DotNet 8 Managed Lambda runtime in placing these .so file. Also please note the added lib i.e. the name liblibSkiaSharp.so (which is NOT in the Zip file).

Expected Behavior

To work as per the DotNet 6 Managed Runtime

Current Behavior

Exception has been thrown by the target of an invocation.

---> System.TypeInitializationException: The type initializer for 'QuestPDF.Settings' threw an exception.

---> QuestPDF.Drawing.Exceptions.InitializationException: The QuestPDF library has encountered an issue while loading one of its dependencies. This type of error often occurs when the current runtime is missing necessary NuGet packages.

Reproduction Steps

Create a Lambda DotNet Application with included Linux libraries

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.3" />

Targeted .NET Platform

.NET Core 8.0

Operating System and version

AWS Lambda

genifycom commented 7 months ago

To fix this, remove:

There is also the SkiaSharp.NativeAssets.Linux.NoDependencies that you can use instead of SkiaSharp.NativeAssets.Linux to avoid this, but you lose out on some advanced font features.

github-actions[bot] commented 7 months ago

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.