libgit2sharp: Unable to load shared library 'git2-7ce88e6' or one of its dependencies.

Hi there,

So I’ve encountered with a quite strange problem when I tried to run my program on ubuntu. As you can see in the log below the app crashes each time when trying to invoke any method from libgit, and it is quite strange cause this project works on Windows10 perfectly.

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
   at LibGit2Sharp.Core.NativeMethods.git_clone(git_repository*& repo, String origin_url, FilePath workdir_path, GitCloneOptions& opts)
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 275
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in C:\projects\libgit2sharp\LibGit2Sharp\Repository.cs:line 779
   at Stt.GitSync.Infrastructure.Managers.RepositoriesManager.CloneIfNotExists(ConfigurationData data) in /home/grimm/Documents/SE/C#/SttGitSync/Stt.GitSync/Infrastructure/Managers/RepositoriesManager.cs:line 96

Unable to load shared library 'git2-7ce88e6' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-7ce88e6: cannot open shared object file: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() in C:\projects\libgit2sharp\LibGit2Sharp\Core\NativeMethods.cs:line 78
   at LibGit2Sharp.Core.NativeMethods..cctor() in C:\projects\libgit2sharp\LibGit2Sharp\Core\NativeMethods.cs:line 56

Reproduction steps

Try to use any LibGit2 method and you get this error

Expected behavior

Repository is cloned

Actual behavior

Exception is raised

Version of LibGit2Sharp (release number or SHA1)

<PackageReference Include="LibGit2Sharp" Version="0.26.1" />
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.289" />

Operating system(s) tested; .NET runtime tested

ubuntu 19.04 netcoreapp2.2

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 29 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I tried mcr.microsoft.com/dotnet/core/sdk:3.1-bionic and it works! 🎉

Apparently, lib2git cant find correct native binaries so I helped it with this trick I had all needed binaries in /app/runtimes/ so i added env variable into my Dockerfile like this

FROM base AS final

ENV LD_LIBRARY_PATH=/app/runtimes/debian.9-x64/native/

work for dotnet core 3.0 (aspnet:3.0-buster-slim)

Same issue here. This library won’t work on Azure app service, Linux. Doing the following settings can solve this issue: image

Encountered the same issue when running in Docker. Changed my runtime from:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

to

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic

solves the problem.

Since the latest preview release should have fixed this, I’m going to go ahead and close it.

this is becoming a problem. Is there any plan to support newer ubuntu versions than 18.x?

It’s not really sustainable to be constantly chasing support for newer platforms for a number of reasons. There needs to be a native binary compiled to match the versions of the dependencies on the distro.

There are plans to sidestep the entire problem by removing as many dependencies as possible from the native binary, enabling a single linux binary to work with most/all distros.

The biggest piece of work remaining to enable this is #1618.

@bording after i vented my frustration i looked at other issues a bit closly and i found that i should use preview release and it worksy was just about to remove my frustrated comment

Raspbian buster (Debian 10 based) has the same Unable to load shared library 'git2-7ce88e6'

I’m using Nuke to build and it’s failing on GitVersion which is using LibGit2Shap.

To be fair, building on a Raspberry Pi is not practical. Much better to cross compile for ARM. It was just curiosity really. Though it does mean I can’t use GitVersion from the command line on the pi either. https://github.com/GitTools/GitVersion/issues/2260

Regarding newer Ubuntu: https://github.com/libgit2/libgit2sharp/pull/1714#issuecomment-533828707

~The most latest NuGet release 0.27-preview works correctly.~

The reason is that since Ubuntu Eoan OpenSSL 1.0 was completely removed from shipping within distro. The same is about the newest Debian.

Shipping a libgit2 linked against OpenSSL 1.1 does the work. https://github.com/libgit2/libgit2sharp/issues/1747#issuecomment-606033076

Try using Ubuntu 18.04

this is becoming a problem. Is there any plan to support newer ubuntu versions than 18.x?