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

LibGit2Sharp not working on sdk:2.2.105-alpine3.9 #314

Closed
ctaggart opened this issue Apr 17, 2019 · 8 comments · Fixed by #322 or #327
Closed

LibGit2Sharp not working on sdk:2.2.105-alpine3.9 #314

ctaggart opened this issue Apr 17, 2019 · 8 comments · Fixed by #322 or #327
Labels

Comments

@ctaggart
Copy link
Contributor

Steps to reproduce:

docker run --rm -it mcr.microsoft.com/dotnet/core/sdk:2.2.105-alpine3.9 sh
dotnet tool install -g nbgv
$HOME/.dotnet/tools/nbgv get-version

Error:

/ # $HOME/.dotnet/tools/nbgv get-version

Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-a904fc6' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libgit2-a904fc6: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path)
   at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths)
   at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo, Boolean useDefaultConfigSearchPaths)
   at Nerdbank.GitVersioning.Tool.Program.OnGetVersionCommand(String projectPath, String format, String singleVariable, String versionOrRef) in D:\a\1\s\src\nbgv\Program.cs:line 261
   at Nerdbank.GitVersioning.Tool.Program.Main(String[] args) in D:\a\1\s\src\nbgv\Program.cs:line 131
Aborted
@ctaggart
Copy link
Contributor Author

Works fine with sdk:2.2.105-alpine3.8.

@ctaggart
Copy link
Contributor Author

Hoping this is fixed by #316

@ctaggart
Copy link
Contributor Author

This does not appear to have been fixed by #316 😢 . Here is how I tested locally:

docker run -it --rm -v ${PWD}:/src -w /src mcr.microsoft.com/dotnet/core/sdk:2.2.105-alpine3.9 sh
dotnet tool install -g nbgv --add-source bin/nbgv/Debug --version 2.3.144-gfd73cbad91
$HOME/.dotnet/tools/nbgv get-version

But still get:

/src # $HOME/.dotnet/tools/nbgv get-version

Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-a904fc6' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libgit2-a904fc6: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path)
   at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths)
   at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo, Boolean useDefaultConfigSearchPaths)
   at Nerdbank.GitVersioning.Tool.Program.OnGetVersionCommand(String projectPath, String format, String singleVariable, String versionOrRef) in C:\Users\taggac\github\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 266
   at Nerdbank.GitVersioning.Tool.Program.Main(String[] args) in C:\Users\taggac\github\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 131
Aborted

@ctaggart
Copy link
Contributor Author

It looks like the alpine-x64 libgit2 lib has a dependency on openssl 1.0, which alpine 3.8 has, but alpine 3.9 updated to 1.1.

binary dependencies:

apk add --update binutils
/src # readelf --all /root/.dotnet/tools/.store/nbgv/2.3.144-gfd73cbad91/nbgv/2.3.144-gfd73cbad91/tools/netcoreapp2.1/any/runtimes/alpine-x64/native/libgit2-a904fc6.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.musl-x86_64.so.1]

https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.8
openssl 1.0.2r-r0

https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.9
openssl 1.1.1b-r1

@bording, any chance we can get native libgit2 binaries that separate out the two?

@bording
Copy link

bording commented Apr 18, 2019

😢

Yeah, looks like we'll need new binaries as long as we've got the OpenSSL dependency. So many headaches because of that. At least we were able to get rid of curl.

I'll try and get a preview package out this weekend.

@ctaggart
Copy link
Contributor Author

I was surprised by the openssl dependency with curl gone. It would be amazing if the openssl dependency could be removed too.

@bording
Copy link

bording commented Apr 18, 2019

The problem is that libgit2 requires it to be able to talk to https remotes. The only way we'd realistically be able to drop it from LibGit2Sharp would be to compile libgit2 without https support, and then implement the support in managed code instead using the hooks libgit2 has for custom transports. There are concerns that it would be noticeably slower, though.

Doing that would drastically simplify the native binaries story though. At that point the only real dependency we'd be impacted by is what libc a distro uses.

@bording
Copy link

bording commented Apr 20, 2019

Give LibGit2Sharp 0.27.0-preview-0007 a try. The native binaries package it references includes an alpine.3.9-x64 binary.

mausch added a commit to mausch/nerdbank-gitversioning that referenced this issue Jun 27, 2019
…image instead of the SDK image.

This brings the final image size to 230MB down from 1.8GB.
Tried using alpine but ran into libgit2 issues (maybe related to dotnet/Nerdbank.GitVersioning#314 )
andrewlock pushed a commit to andrewlock/nerdbank-gitversioning that referenced this issue Jun 27, 2019
…image instead of the SDK image.

This brings the final image size to 230MB down from 1.8GB.
Tried using alpine but ran into libgit2 issues (maybe related to dotnet/Nerdbank.GitVersioning#314 )
AArnott added a commit that referenced this issue Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants