You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to load shared library 'git2-8a0dc67' or one of its dependencies #1914
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)
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.
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.
Activity
dradovic commentedon 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 sameruntimessubfolders. So the building is consistent. It's definitely a runtime problem.pattyr commentedon 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-x64version of thelibgit2-*.sodotnet publish provided.To mitigate, the
libgit2-*.sofor runtimerhel-x64was copied and put alongside the project files.Then added that
libgit2-*.soto 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 commentedon 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.