Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac executable is not statically linked #100

Open
alecthomas opened this issue Jan 22, 2022 · 4 comments · May be fixed by jzelinskie/homebrew-faq#2
Open

Mac executable is not statically linked #100

alecthomas opened this issue Jan 22, 2022 · 4 comments · May be fixed by jzelinskie/homebrew-faq#2

Comments

@alecthomas
Copy link

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
Copy link

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
Copy link

reegnz commented Jul 24, 2023

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
Copy link

reegnz commented Jul 24, 2023

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 added a commit to reegnz/homebrew-faq that referenced this issue Jul 24, 2023
The pre-built binary the formula downloaded is broken when used on newer macs where the homebrew prefix is not `/usr/local` but `/opt/homebrew`.

The formula should rely on homebrew telling where the library is, and build with CGO using that info.

To avoid incompatible installs, use the `bottle` mechanism of homebrew to fetch prebuilt packages (eg. for older macos versions and architectures), and leave installation by rebuilds open to newer architectures not having prebuilt bottles.

Fixes jzelinskie/faq#100
@reegnz
Copy link

reegnz commented Jul 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants