Skip to content

AWS Lambda - Unable to load library #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
boemekeld opened this issue Aug 10, 2020 · 2 comments
Open

AWS Lambda - Unable to load library #1823

boemekeld opened this issue Aug 10, 2020 · 2 comments

Comments

@boemekeld
Copy link

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.

@boemekeld
Copy link
Author

I found a workaround:
The rhel-x64 runtime version of libgit2-ef5a385.so works on Amazon Linux 2.

@Wolftousen
Copy link

Thanks for this. Our build agent wasn't dropping the SO in at all, so i just ran publish locally grabbed the appropriate one and added it as an include on the csproj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants