Repository navigation
Unable to load shared library 'git2-7ce88e6' or one of its dependencies. #1703
Description
Activity
Hi,
the same issue on my Mac.
10.14.5 (18F132) (Mojave)On windows everything works fine.
Rolling back to 0.26.0 works.
Best regards
Hmm, I've tried to create the empty project which just clones the public repository. and this error occurs again and again, and the version of libgit does not matter. I've also attached my .csproj, probably I've done something wrong.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.2</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="LibGit2Sharp" Version="0.26.0" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="System.Reactive" Version="4.1.3" /> </ItemGroup> </Project>I have the same issue too when running in Azure Functions
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 thisFROM base AS final
ENV LD_LIBRARY_PATH=/app/runtimes/debian.9-x64/native/
work for dotnet core 3.0 (aspnet:3.0-buster-slim)
Reacted by Kenneth Choe, Felipe Cruz, hiren929, krenting and Alex AndroshchukReacted by krentingAs of now libgit2sharp provides the native libraries for the following linux distributions,
win-x86
win-x64
win-arm64
win
unix
ubuntu.18.04-x64
ubuntu.16.04-arm64
rhel-x64
osx
linux-x64
fedora-x64
debian.9-x64
debian-arm64
alpine.3.9-x64
alpine-x64In such case using ubuntu 19.04 is not going to work. Try using Ubuntu 18.04 and see if it works.
Otherwise try switching to any of the above mentioned linux distributions.
/root/.nuget/packages/gitversiontask/5.1.2/build/GitVersionTask.targets(10,9): error : PlatformNotSupportedException: debian.9-arm64
Tried different arm64 distributions with no luck.Encountered the same issue when running in Docker. Changed my runtime from:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1to
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionicsolves the problem.
Reacted by Ilia Tsvetkov, Andre Carlucci, Traian Scrob and Alex AndroshchukI tried
mcr.microsoft.com/dotnet/core/sdk:3.1-bionicand it works! 🎉Reacted by Igor Fedchenko, Thomas, Andre Carlucci, Ichiryuu, Traian Scrob and Alex AndroshchukFor me, it worked with
mcr.microsoft.com/dotnet/core/sdk:3.1-alpineandmcr.microsoft.com/dotnet/core/runtime:3.1-alpine.Thanks
Looks like the problem is that the binary
git2-7ce88e6is built to the wrong directory, so the program is not able to load it when it look for it in the right one.What worked for me was adding an MSBuild
PostBuildEventto.csprojwhich copies thegit2-7ce88e6binary from the directory it was built, to the directory it is expected to run from.
These directories might differ, so it is better to check them manually.Try using Ubuntu 18.04
this is becoming a problem. Is there any plan to support newer ubuntu versions than 18.x?
Reacted by Em Kaythis 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.
Reacted by Ilia Tsvetkov and Aloïs de GouvelloRegarding newer Ubuntu:
#1714 (comment)The most latest NuGet release0.27-previewworks 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.
#1747 (comment)Reacted by dradovicRaspbian 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. GitTools/GitVersion#2260
Reacted by chenxuuu8 remaining items
Since the latest preview release should have fixed this, I'm going to go ahead and close it.
Reacted by Edward Thomson and Em Kay- added a commit that references this issue
on Jul 21, 2021 - added a commit that references this issue
on Aug 14, 2021 I'm on the latest preview (0.27.0-preview-0007) and this is not working on aspnet:5.0-buster-slim, which according to: https://hub.docker.com/_/microsoft-dotnet-aspnet is a debian 10 image. Could someone advise on the preview version/dotnet5 image combo I should be using please?
@csurfleet The latest preview version is 0.27.0-preview-0119, so give that a try.
@bording I'm experiencing the same problem with 0.27.0-preview-0119 on the Bitbucket CI/CD infrastructure. Unfortunately, it's not appearing consistently (I guess it depends what actual build agent is chosen to build the solution). The error I'm seeing sporadically is:
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 directoryAs this is a closed issue, I've opened #1914 for this.
As of now libgit2sharp provides the native libraries for the following linux distributions, win-x86 win-x64 win-arm64 win unix ubuntu.18.04-x64 ubuntu.16.04-arm64 rhel-x64 osx linux-x64 fedora-x64 debian.9-x64 debian-arm64 alpine.3.9-x64 alpine-x64
In such case using ubuntu 19.04 is not going to work. Try using Ubuntu 18.04 and see if it works.
Otherwise try switching to any of the above mentioned linux distributions.
Where can I find this list?
I was able to make gitversion work using libssl1.1. But it does not work for Ubuntu 20.04.
If I could find the updated list for libgit2sharp , I could figure out which image I can use it withAs of now libgit2sharp provides the native libraries for the following linux distributions, win-x86 win-x64 win-arm64 win unix ubuntu.18.04-x64 ubuntu.16.04-arm64 rhel-x64 osx linux-x64 fedora-x64 debian.9-x64 debian-arm64 alpine.3.9-x64 alpine-x64
In such case using ubuntu 19.04 is not going to work. Try using Ubuntu 18.04 and see if it works.
Otherwise try switching to any of the above mentioned linux distributions.Where can I find this list? I was able to make gitversion work using libssl1.1. But it does not work for Ubuntu 20.04. If I could find the updated list for libgit2sharp , I could figure out which image I can use it with
Way back in 2019 when I posted this answer, I was using LibGit2Sharp.NativeBinaries v2.0.289 and libgit2sharp was providing the native libraries for the distributions I have mentioned. You can look at the list here under runtimes directory in the following link https://nuget.info/packages/LibGit2Sharp.NativeBinaries/2.0.289
The latest version of libgit2sharp v0.27.0-preview-0119 has a dependency on LibGit2Sharp.NativeBinaries v2.0.315-alpha.0.1, the native libraries supported can be found here https://nuget.info/packages/LibGit2Sharp.NativeBinaries/2.0.315-alpha.0.1
If you are using libgit2sharp v0.26.2, then it has a dependency on LibGit2Sharp.NativeBinaries v2.0.306, the native libraries supported can be found here https://nuget.info/packages/LibGit2Sharp.NativeBinaries/2.0.306
- added a commit that references this issue
on Feb 9, 2022 - added a commit that references this issue
on Nov 23, 2022 Hitting the same problem trying to run LibGit2Sharp in AWS lambda
EDIT: Managed to hack around the issue based on advice from these two comments:
aws/aws-lambda-dotnet#716 (comment)...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.
The rhel-x64 runtime version of libgit2-ef5a385.so works on Amazon Linux 2.
The
libgit2-106a5f2.soincluded with .NET 6 runtime, does not work with AWS. The workaround is to replace the publishedlibgit2-106a5f2.sowith therhel-64/nativeone, located in:.nuget\packages\libgit2sharp.nativebinaries\2.0.306\runtimes\rhel-x64\nativeYou need to replace the so after the project is published, but obviously before you zip it and upload it to AWS. Again based on the above comment I used the following msbuild code for .NET 6 (edit your
...Lambda.csjprojfile):<Project> ... <Target Name="GitLib2SharpFix" AfterTargets="Publish"> <!--See: https://github.com/libgit2/libgit2sharp/issues/1703#issuecomment-1364750879 --> <Exec Command="copy "$(ProjectDir)bin\Release\net6.0\runtimes\rhel-x64\native\libgit2-106a5f2.so" "bin\Release\net6.0\publish\libgit2-106a5f2.so""/> </Target> </Project>
0.27.0-preview
Upgrading to the preview fixed the "Unable to load shared library 'git2-106a5f2' or one of its dependencies"
As I was on alpine, it gave me another error that it is unable to load ssl/open ssl libraries, which I suspect is because alpine is lightweight. I switched to focal version and that fixed the ssl problem too.
I found a work around for this, when using the dotnet:sdk6.0-alpine image. I used strace to determine it was loading the library from
/app/runtimes/alpine.3.9-x64/native/libgit2-106a5f2.so. So I installed libgit2 from apk and overrode that file with the system version. This is what it looks like in aDockerfile:FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine RUN apk add git libgit2 COPY my_app/bin/Release/net6/publish/ /app/ RUN cp /usr/lib/libgit2.so.1.5 /app/runtimes/alpine.3.9-x64/native/libgit2-106a5f2.so
I would expect this sort of approach to work for any base image that can install a system libgit2, since the system libgit2 will be compatible with the system, while the native-managed invocations won't be tightly coupled, meaning the precise version of libgit2 isn't relevant to LibGit2Sharp, as long as all the entry points it calls are present.
I'm now building libgit2sharp on FreeBSD and also getting this error for obvious reason.
I'm actually surprised that libgit2sharp tries to ship all the possible variants of the native library rather than having an option to use (or at least to fallback to) a system libgit2.so coming from the OS package manager.

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.
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)
Operating system(s) tested; .NET runtime tested
ubuntu 19.04
netcoreapp2.2