Skip to content

Cannot find native library. #786

Closed
Closed
@phrohdoh

Description

@phrohdoh

No matter where I put the native library libgit2sharp refuses to fine it.
The tiny project can be found here.

using System;
using System.IO;
using System.Linq;
using LibGit2Sharp;

namespace GitSharp
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("\targ1: output dir\n\targ2: repo http url");
                return;
            }

            var outputDir = Path.Combine(Environment.CurrentDirectory, args[0]);

            if (!Directory.Exists(outputDir))
                Directory.CreateDirectory(outputDir);

            Console.WriteLine("Output: {0}", outputDir);

            var repoSource = args[1];
            Console.WriteLine("Repo: {0}", repoSource);

            var native = File.Exists("git2-90befde.dll");
            Console.WriteLine("Native exist: {0}", native);

            var path = Repository.Clone(repoSource, outputDir);

            using (var repo = new Repository(path))
            {
                Console.WriteLine("Branches {0}.", repo.Branches.Count());
            }
        }
    }
}

$ mono --debug GitSharp.exe out https://github.com/Phrohdoh/libdrs
crashes with

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.DllNotFoundException: git2-90befde
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.String workdirPath, LibGit2Sharp.CloneOptions options) [0x00000] in <filename unknown>:0 
  at GitSharp.MainClass.Main (System.String[] args) [0x00067] in /Users/thill/Projects/GitSharpTest/GitSharp/GitSharp/Program.cs:31 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.DllNotFoundException: git2-90befde
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.String workdirPath, LibGit2Sharp.CloneOptions options) [0x00000] in <filename unknown>:0 
  at GitSharp.MainClass.Main (System.String[] args) [0x00067] in /Users/thill/Projects/GitSharpTest/GitSharp/GitSharp/Program.cs:31
iMac:Debug thill$ ls
./                ../               GitSharp.exe*     GitSharp.exe.mdb  LibGit2Sharp.dll  git2-90befde.dll  out/

I've included binaries in that repo in hopes of resolving this easier.
Sorry if this is too long / unhelpful issue.

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