From e3f2c2442084303b08c194e012a9c76dcc074f88 Mon Sep 17 00:00:00 2001 From: David Zhang Date: Sun, 26 Jun 2022 10:22:16 -0400 Subject: [PATCH] prioritize /opt/homebrew/lib for macos on aarch64 for searching path --- lib/ffi/library.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb index 43b2bfe15..c05a007f3 100644 --- a/lib/ffi/library.rb +++ b/lib/ffi/library.rb @@ -126,7 +126,12 @@ def ffi_lib(*names) else # TODO better library lookup logic unless libname.start_with?("/") || FFI::Platform.windows? - path = ['/usr/lib/','/usr/local/lib/','/opt/local/lib/', '/opt/homebrew/lib/'].find do |pth| + path_candidates = if FFI::Platform::ARCH == 'aarch64' && FFI::Platform.mac? + ['/opt/homebrew/lib/', '/usr/lib/','/usr/local/lib/','/opt/local/lib/'] + else + ['/usr/lib/','/usr/local/lib/','/opt/local/lib/', '/opt/homebrew/lib/'] + end + path = path_candidates.find do |pth| File.exist?(pth + libname) end if path