libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.13k stars 879 forks source link

Running on linux requires libssl 1.0, thus fails #2003

Closed billybraga closed 7 months ago

billybraga commented 1 year ago

Reproduction steps

Expected behavior

Repo is cloned

Actual behavior

An exception is thrown:

System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
    System.DllNotFoundException: Unable to load shared library 'git2-106a5f2' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/runtimes/linux-x64/native/git2-106a5f2.so: cannot open shared object file: No such file or directory
/home/USER/.dotnet/shared/Microsoft.NETCore.App/7.0.1/git2-106a5f2.so: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/git2-106a5f2.so: cannot open shared object file: No such file or directory
libssl.so.1.0.0: cannot open shared object file: No such file or directory
/home/USER/.dotnet/shared/Microsoft.NETCore.App/7.0.1/libgit2-106a5f2.so: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/libgit2-106a5f2.so: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/runtimes/linux-x64/native/git2-106a5f2: cannot open shared object file: No such file or directory
/home/USER/.dotnet/shared/Microsoft.NETCore.App/7.0.1/git2-106a5f2: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/git2-106a5f2: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/runtimes/linux-x64/native/libgit2-106a5f2: cannot open shared object file: No such file or directory
/home/USER/.dotnet/shared/Microsoft.NETCore.App/7.0.1/libgit2-106a5f2: cannot open shared object file: No such file or directory
/home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/libgit2-106a5f2: cannot open shared object file: No such file or directory

Using LD_DEBUG=files, I get this (among other things): 10607: file=libssl.so.1.0.0 [0]; needed by /home/USER/dev/projects/PROJECT/src/PROJECT.Cli/bin/Release/net7.0/runtimes/linux-x64/native/libgit2-106a5f2.so

Version of LibGit2Sharp (release number or SHA1)

0.26.2

Operating system(s) tested; .NET runtime tested

billybraga commented 1 year ago

I guess something must have changed since #1747, since it seemed to work after it had bee fixed.

billybraga commented 1 year ago

Seems like 0.27.0-preview-0182 solves this problem. Is it to be released soon?

Miepee commented 1 year ago

@billybraga have you tried checking whether 0182 preview fixes it also for other distros (i.e fedora, arch)? It didn't work for me sadly.

billybraga commented 1 year ago

@Miepee No, I have only tested on Ubuntu

d0pare commented 1 year ago

Preview package fixed the issue on RHEL 7.9 Linux.

mirkomaty commented 1 year ago

I had the same error on Ubuntu 22.04. After upgrading to the newest preview (0.27.0-preview-0182) the dependency isn't there anymore, but it seems that the problem remains and shows up at runtime:

LibGit2Sharp.LibGit2SharpException: could not load ssl libraries
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage) in /_/LibGit2Sharp/Core/Proxy.cs:line 2289
   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage) in /_/LibGit2Sharp/Commands/Fetch.cs:line 80
   at ...

Any ideas?

Miepee commented 1 year ago

So seems like there's something else that influences it too then, if the issue both happens and doesn't happen on ubuntu 22.04 with the same preview package.

@mirkomaty if you set LD_DEBUG=files, do you also see the same as in the first comment?

bording commented 7 months ago

This should be fixed in the latest releases.