Repository navigation
Unable to load shared library 'git2-ef5a385' or one of its dependencies #716
Description
Activity
- addedbugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
on Aug 10, 2020 A Console Application works:
docker run -it lambci/lambda:build-dotnetcore3.1 bash
dotnet new console --name GitLibOnAWSLinux
cd GitLibOnAWSLinux
dotnet add package LibGit2Sharp --version 0.27.0-preview-0034
-- Program.cs - add "new LibGit2Sharp.Repository();"
dotnet build
dotnet runHello World!
- addedguidanceQuestion that needs advice or information.Question that needs advice or information.needs-reproductionThis issue needs reproduction.This issue needs reproduction.and removedbugThis issue is a bug.This issue is a bug.
on Aug 10, 2020 Hi @boemekeld,
Thanks for posting the issue!
I tried to reproduce the issue on Mac OS Terminal. I was successfully able to invoke the Lambda function without any issues. I also see in the Lambda publish logs, the file libgit2-ef5a385.so is included in the output.
Based on above testing, it appears that for certain environments, the file libgit2-ef5a385 is not found in the PATH and hence not copied to the output directory.
There are multiple issues related to the native libgit2 library reported by users on GitHub libgit2sharp repository, including Issue 1703. It appears that it's may or may not be supported on some platforms and also mentions about it's dependency on OpenSSL. I also see a pull request 1714 which attempts to fix this issue for some platforms.
So the issue doesn't appear to be related to Lambda environment, instead the platform used to deploy to AWS Lambda where libgit2 library not being included in publish process.
As mentioned in the issue, the Lambda function works fine when published using Amazon Linux. I will give it a try on Windows 10 and let you know the outcome.
Thanks,
AshishHi @ashishdhingra, thanks for answering.
I confirmed that the issues reported in the LibGit2Sharp repository are not related to this problem.
The file libgit2-ef5a385.so is being included in the publish output.
I also found a workaround:
Run publish without specifying the "runtime" parameter. In this way, several "runtimes" will be generated.
Copying the libgit2-ef5a385.so file from the rhel-x64 runtime and replacing it within the ZIP works.That is, I believe that the linux-x64 runtime libgit2-ef5a385.so is incompatible with AWS Linux. On the other hand, the rhel-x64 runtime works.
At this point, I set up a Post-Publish script to replace the file:
<Target Name="GitLib2SharpFix" AfterTargets="Publish"> <Exec Command="copy libgit2-ef5a385.so bin\Release\netcoreapp3.1\publish" /> </Target>Do you know a better way to solve this?
Reacted by Arturo Monge, Denys Zhuravel and Eternal21Reacted by Eternal21Hi @boemekeld,
Good to see that you were able to find the workaround. After your reply, I was about to propose the same workaround as you mentioned. I think this is the good workaround for the time being until further support for more platforms is added in the library or fix to remove dependency on native libraries is published (I do see there was some failing PR in libgit2sharp repository, not sure if that would provide permanent fix in future).
Please let me if workaround implemented by you is good for now and confirm if we could close this issue.
Thanks,
Ashish- addedresponse-requestedWaiting on additional info and feedback. Will move to close soon in 7 days.Waiting on additional info and feedback. Will move to close soon in 7 days.and removedneeds-reproductionThis issue needs reproduction.This issue needs reproduction.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
on Aug 10, 2020 Yes, thanks for your time.
Description
I'm trying to use a library called GitLib2Sharp, but an error occurs when trying to load it.
I tried to reproduce this problem on an Amazon Linux EC2, but the error did not occur.
Reproduction Steps
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"
Logs
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
Environment
I analyzed several related issues in the GitLib2Sharp and Docker repositories but I was unable to solve this problem.
Please help me.
This is a 🐛 bug-report