Skip to content

System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so on Ubuntu Linux #1585

Description

@evil-shrike

I have difficulties with LibGit2Sharp while running Cake (with Cake.Git addin) build on Linux Ubuntu 16.04 in Docker - cake-contrib/Cake_Git#68
But I managed to isolate issue with LibGit2Sharp only.

Reproduction steps

touch gt.cs

usingLibGit2Sharp;usingSystem;publicclassProgram{publicstaticvoidMain(){Console.WriteLine("HI");varrepo=newRepository("/opt/buildagent/work/e1fb3d71588668ec");}}

csc gt.cs /r:LibGit2Sharp.dll

mono gt.exe

HI
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at Program.Main () [0x0000c] in <f40fe756e0ec4a4d9aed452251bd0a53>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0
at Program.Main () [0x0000c] in <f40fe756e0ec4a4d9aed452251bd0a53>:0

Mono looks up for native module in subfolder bacause of config

cat LibGit2Sharp.dll.config

<configuration>
<dllmapos="linux"cpu="x86-64"wordsize="64"dll="git2-1196807"target="lib/linux/x86_64/libgit2-1196807.so" />
<dllmapos="osx"cpu="x86,x86-64"dll="git2-1196807"target="lib/osx/libgit2-1196807.dylib" />
</configuration>

the file lib/linux/x86_64/libgit2-1196807.so does exist. also tried to copy it besides my .exe module.

Expected behavior

no error

Actual behavior

System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so

Version of LibGit2Sharp (release number or SHA1)

libgit2-1196807.so

Operating system(s) tested; .NET runtime tested

# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
# mono --version
Mono JIT compiler version 5.12.0.226 (tarball Thu May 3 09:48:32 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: supported, not enabled.
GC: sgen (concurrent by default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions