From d55742d6d7725fa190df0caf3c1cbe60b7b481aa Mon Sep 17 00:00:00 2001 From: Dillon Nys <24740863+dnys1@users.noreply.github.com> Date: Wed, 10 Aug 2022 09:43:28 -0700 Subject: [PATCH] chore: Lookup library in system path (#75) --- lib/src/util.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/util.dart b/lib/src/util.dart index 8ce2caf..368f84c 100644 --- a/lib/src/util.dart +++ b/lib/src/util.dart @@ -53,6 +53,18 @@ String? _resolveLibPath(String name) { libPath = path.join(path.dirname(Platform.resolvedExecutable), 'lib', name); if (_doesFileExist(libPath)) return libPath; + // If lib is installed in system dir. + if (Platform.isMacOS || Platform.isLinux) { + final paths = [ + '/usr/local/lib/libgit2.$libgit2Version.dylib', + '/usr/local/lib/libgit2.so.$libgit2Version', + '/usr/lib64/libgit2.so.$libgit2Version' + ]; + for (final path in paths) { + if (_doesFileExist(path)) return path; + } + } + String checkCache(PubCache pubCache) { final pubCacheDir = pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;