jzelinskie / faq

Format Agnostic jQ -- process various formats with libjq
Apache License 2.0
439 stars 14 forks source link

Mac executable is not statically linked #100

Open alecthomas opened 2 years ago

alecthomas commented 2 years ago

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
NightMachinery commented 1 year ago

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)
reegnz commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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