From 921ea25422e8dfbb7afe9a91f9019fe210960457 Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Tue, 9 Aug 2022 17:26:52 -0700 Subject: [PATCH] chore: Lookup library in system path --- 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;