Skip to content
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

Unable to load shared library 'git2-8a0dc67' or one of its dependencies #1914

Closed
dradovic opened this issue Sep 24, 2021 · 3 comments
Closed

Comments

@dradovic
Copy link

Reproduction steps

We sporadically experience the following exception in our Bitbucket CI environment, when a test tries to use the LibGit2Sharp library:

System.TypeInitializationException : The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
---- System.DllNotFoundException : Unable to load shared library 'git2-8a0dc67' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-8a0dc67: cannot open shared object file: No such file or directory
Stack Trace:
at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
at LibGit2Sharp.Repository..ctor(String path)

Version of LibGit2Sharp (release number or SHA1)

<PackageReference Include="LibGit2Sharp" Version="0.27.0-preview-0119" />

Operating system(s) tested; .NET runtime tested

The tests are running against the mcr.microsoft.com/dotnet/sdk:5.0.202 image.

@dradovic
Copy link
Author

dradovic commented Sep 24, 2021

I want to add that I was never able to reproduce this issue in complete isolation. Even in the CI. It occurs only sporadically, when all tests run (many of them in parallel). However, there's only one test that uses the LibGit2Sharp nuget.

So I'm wondering what (race) conditions might cause that library not to be found.

I've also compared the build output directories of a successful with a failed run, and in both cases I see the libgit2-8a0dc67.* files in the same runtimes subfolders. So the building is consistent. It's definitely a runtime problem.

@pattyr
Copy link

pattyr commented Oct 14, 2021

Hello!

We got the same error (with different sha) in a Lambda function recently.

Found the that it didn't like the linux-x64 version of the libgit2-*.so dotnet publish provided.

To mitigate, the libgit2-*.so for runtime rhel-x64 was copied and put alongside the project files.

Then added that libgit2-*.so to be copied to output directory in the *.csproj.

Here's an example to reproduce the issue. It includes the "fix" described.

Hope that can help some! 😃

@dradovic
Copy link
Author

dradovic commented Nov 8, 2021

I've found the what was causing the instability of our CI: it seems the culprit was a test that was using the Buildalyzer.Workspaces package (v3.2.3) which in turn uses Roslyn (Microsoft.CodeAnalysis.CSharp.Workspaces) to compute certain code statistics. Once I had deactivated that test, the problem never appeared again.

@dradovic dradovic closed this as completed Nov 8, 2021
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