faq icon indicating copy to clipboard operation
faq copied to clipboard

Mac executable is not statically linked

Open alecthomas opened this issue 3 years ago • 4 comments

I'm only filing this because the README states that they are:

$ faq
dyld: Library not loaded: /usr/local/opt/jq/lib/libjq.1.dylib
  Referenced from: /Users/aat/Library/Caches/hermit/pkg/faq-0.0.7/faq
  Reason: image not found

alecthomas avatar Jan 22 '22 21:01 alecthomas

Indeed, it doesn't work at all even though I have jq installed via brew:

dyld[88077]: Library not loaded: /usr/local/opt/jq/lib/libjq.1.dylib
  Referenced from: <B16C395F-8D62-37E5-9707-14ACF7A8DA8B> /opt/homebrew/Cellar/faq/0.0.7/bin/faq
  Reason: tried: '/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/usr/local/lib/libjq.1.dylib' (no such file), '/usr/lib/libjq.1.dylib' (no such file, not in dyld cache)

I tried linking the library forcefully, but the architectures aren't compatible:

dyld[90745]: Library not loaded: /usr/local/opt/jq/lib/libjq.1.dylib
  Referenced from: <B16C395F-8D62-37E5-9707-14ACF7A8DA8B> /opt/homebrew/Cellar/faq/0.0.7/bin/faq
  Reason: tried: '/usr/local/opt/jq/lib/libjq.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/usr/local/opt/jq/lib/libjq.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libjq.1.dylib' (no such file), '/usr/lib/libjq.1.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/jq/HEAD-cff5336/lib/libjq.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/jq/HEAD-cff5336/lib/libjq.1.dylib' (no such file), '/opt/homebrew/Cellar/jq/HEAD-cff5336/lib/libjq.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libjq.1.dylib' (no such file), '/usr/lib/libjq.1.dylib' (no such file, not in dyld cache)

NightMachinery avatar Dec 12 '22 14:12 NightMachinery

Ran into the same issue:

dyld[17317]: Library not loaded: /usr/local/opt/jq/lib/libjq.1.dylib
  Referenced from: <B16C395F-8D62-37E5-9707-14ACF7A8DA8B> /opt/homebrew/Cellar/faq/0.0.7/bin/faq
  Reason: tried: '/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/usr/local/opt/jq/lib/libjq.1.dylib' (no such file), '/usr/local/lib/libjq.1.dylib' (no such file), '/usr/lib/libjq.1.dylib' (no such file, not in dyld cache)
[2]    17317 abort      faq -h

Root cause is that on newer macs (like the M1, M2 ones), homebrew is not installed under /usr/local but under /opt/homebrew. The formula should respect that.

reegnz avatar Jul 24 '23 08:07 reegnz

Huh, formula is pretty basic: https://github.com/jzelinskie/homebrew-faq/blob/master/Formula/faq.rb

So I guess the problem is not how the formula passes the libjq dependency, but that it doesn't pass it at all! Because faq is not built by homebrew so it can pass the prefix, but instead built by github actions assuming libjq is always found under /usr/local, and the build binary is pulled from the repo.

I think the fix should probably be to have the Formula build the binary instead of downloading the binary from github.

reegnz avatar Jul 24 '23 08:07 reegnz

Pushed a fix for the homebrew formula to build from source instead of fetching pre-built binaries with faulty dynamic linking.

reegnz avatar Jul 24 '23 10:07 reegnz