Skip to content

AWS Lambda - Unable to load library #1823

Open
@boemekeld

Description

@boemekeld

Reproduction steps

dotnet tool install -g Amazon.Lambda.Tools
dotnet new --install Amazon.Lambda.Templates
dotnet new lambda.EmptyFunction --name LambdaGit
cd LambdaGit/src/LambdaGit
dotnet add package LibGit2Sharp --version 0.27.0-preview-0034
--- add "new LibGit2Sharp.Repository();" in "FunctionHandler" function in "Function.cs"
dotnet lambda deploy-function LambdaGit --function-role LambdaGitRole
dotnet lambda invoke-function LambdaGit --payload "LambdaOK"

Actual behavior

Payload:
{
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.",
"stackTrace": [
"at LibGit2Sharp.Core.NativeMethods.git_repository_new(git_repository*& repo)",
"at LibGit2Sharp.Core.Proxy.git_repository_new()",
"at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)",
"at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
],
"cause": {
"errorType": "DllNotFoundException",
"errorMessage": "Unable to load shared library 'git2-ef5a385' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-ef5a385: cannot open shared object file: No such file or directory",
"stackTrace": [
"at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()",
"at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()",
"at LibGit2Sharp.Core.NativeMethods..cctor()"
]
}
}

Log Tail:
START RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73 Version: $LATEST
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.: TypeInitializationException
at LibGit2Sharp.Core.NativeMethods.git_repository_new(git_repository*& repo)
at LibGit2Sharp.Core.Proxy.git_repository_new()
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
at lambda_method(Closure , Stream , Stream , LambdaContextInternal )

at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
at LibGit2Sharp.Core.NativeMethods..cctor()

END RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73
REPORT RequestId: 0e940c07-4526-411d-9f47-ffbfc2cd3a73 Duration: 702.47 ms Billed Duration: 800 ms Memory Size: 256 MB Max Memory Used: 69 MB Init Duration: 156.11 ms

Version of LibGit2Sharp (release number or SHA1)

I tested all 84 available versions of GitLib2Sharp on Nuget. None of them worked.

Operating system(s) tested; .NET runtime tested

Amazon Linux 2
.NET Platform: 3.1

I analyzed several related issues in the GitLib2Sharp, aws-lambda-dotnet and Docker repositories but I was unable to solve this problem.

Please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions