-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Library not loaded: libpact_ffi.dylib #345
Comments
thx for the thorough report, we’ve had the same on Slack. is this with ventura 13.6? i wonder if they’ve changed dyld load paths. it’s late now but will investigate tomorrow. i have vms running amd64 and arm64 so will pull down the ipsw’s and test this out |
Been able to replicate that now on my work laptop ❯ DYLD_LIBRARY_PATH=/usr/local/lib go test main/consumer_test.go
ok command-line-arguments 0.054s
❯ go test main/consumer_test.go
Alias tip: got main/consumer_test.go
dyld[58542]: Library not loaded: libpact_ffi.dylib
Referenced from: <9E73780A-35B2-3074-8A0D-96B50CDAD065> /private/var/folders/2j/z1vzhzfj3g75d7cwc039m8280000gs/T/go-build759910136/b001/main.test
Reason: tried: 'libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpact_ffi.dylib' (no such file), 'libpact_ffi.dylib' (no such file), '/Users/yousaf.nabi/dev/you54f/go-pact-test/go-1/main/libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/yousaf.nabi/dev/you54f/go-pact-test/go-1/main/libpact_ffi.dylib' (no such file), '/Users/yousaf.nabi/dev/you54f/go-pact-test/go-1/main/libpact_ffi.dylib' (no such file)
signal: abort trap
FAIL command-line-arguments 0.017s
FAIL
[🔴 ERROR] ❯ go version
Alias tip: gove
go version go1.21.1 darwin/arm64
❯ sw_vers
ProductName: macOS
ProductVersion: 13.6
BuildVersion: 22G120
❯ otool -L /usr/local/lib/libpact_ffi.dylib
/usr/local/lib/libpact_ffi.dylib:
libpact_ffi.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1953.255.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60420.60.24)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) |
It appears to only be possible either by modifying adding to the
Some useful posts around DYLD* https://hynek.me/articles/macos-dyld-env/ The latter is used by Traveling-ruby, using It is also used in pact-js-core It would probably make sense for it to be invoked when we are using a custom libDir, so that we can lookup. I note you are running go1.20 on an intel Mac. We've had the same report on a 13.5.1 apple silicon machine. https://pact-foundation.slack.com/archives/C9UTHTFFB/p1695927031221869 |
I've also encountered this issue on Go: 1.21.1 MacOSX : 14 Apple Silicon |
Yeah, this is with 13.6 for me. I think I saw a line in Apple XCode latest release notes that they rewrote the linker, could it be the root cause? Interesting that for you dyld_library_path is propagated correctly to the go test here:
cause for me (albeit with dyld_fallback_library_path) I had to run go test -exec with a custom script to set the value. Also, here's the doc I found the most helpful around dyld and linking: |
On
Worth testing if rpath is resolved correctly with go. |
I'll try to send some PRs next week, thanks for all the info Yousaf!
Yes that would explain it. For macfuse, can you run |
so the full path is why it works out of the box, cool |
I'm wondering if we should report this to apple, but I'm not really sure how their bug reporting tool works |
You could do, seems like the way it to do it through apple developer website and log a ticket, from what I've read in the apple forums. Guide from Eskimo - who is super helpful on the forums - https://developer.apple.com/forums/thread/712889 (works for Apple) FYI I've just been testing this locally, I get the same error running the tests (can't find lib), and updating the install_name_tool invocation as you suggested and everything is working as expected - as per bindfs, we have our full path to wherever the user specifies the lib to be installed otool -D /tmp/libpact_ffi.dylib
/tmp/libpact_ffi.dylib:
/tmp/libpact_ffi.dylib I think this might be a sensible way to go. I'll test it out against older versions of MacOS over the weekend Thanks for investigating dude |
Thanks! I'll try to come up with a concise report to apple next week. |
First of all, thank you for the very detailed bug report and investigation - this is super helpful and I really appreciate the time you took to report it.
Yes, that's one option, another is to specify the other pre-configured search path (
Possibly, I don't know. It might mean it can only be installed into On
This is what lib.go is aiming to do. If we can improve this, I'm all ears. I can't quite remember the details now, but I remember it you couldn't do this like "check the ~/.pact/libs` directory" because it couldn't determine that at link / compilation time. It's possibly it is doable though, and I just didn't quite know how to make it all work at the time. TL;DR - I would definitely appreciate a PR. I think if we encode the full path that corresponds to what is passed to |
So it seems I came across this a few months when trying to get this running for MacOS in CI Run here https://github.com/YOU54F/pact-go/actions/runs/5544271940/job/15016645245 Tried some changes to support testing x platform, managed to recreate the issue on MacOS and resolve with a full path in install name tool, but have a failing test on arm64 |
Created #350 - a simple fix really, with using absolute path for install_name. I can't think of downsides, but since I'm very new to building and linking native libs, might be missing some finer details? doesn't look like it tho. I don't have an arm64 machine handy to test the fix, will ask the colleagues. |
Searching apple forums and it seems it's been reported multiple times already, e.g. here: |
fix: set install_name to absolute path for libpact_ffi.dylib (#345)
I have an arm64 and it works on my machine. I'm just sorting through some other minor admin and will get a release out today. |
|
We confirmed this works for us as well. Thanks @stan-confluent! |
Thanks Matt for quick review and release! I'll let you know if something doesn't work. |
Thanks all, great teamwork 👏 |
Apologies in advance for a long post.
This issue started happening to me seemingly from the latest MacOS update, but might've been caused by some other changes on the system.
I'm wondering if this is local to my system or if others have experienced this too?
Basically just trying to run
go test ...
with pact-go causes issues loadinglibpact_ffi.dylib
:Note how the log doesn't mention looking at
/usr/local/lib
or/usr/lib
.I'm not 100% sure, but I suspect that previously
DYLD_FALLBACK_LIBRARY_PATH
was set to a default value of/usr/local/lib:/usr/lib
, ordyld
had these defaults hardcoded if the variable was unset, but not anymore.So it used to be able to find
libpact_ffi.dylib
in fallback path, but not anymore.Some more details.
pact-go
installslibpact_ffi.dylib
under/usr/local/lib
by default.pact-go
also invokesinstall_name_tool -id libpact_ffi.dylib /usr/local/lib/libpact_ffi.dylib
.This sets the id / install name of the lib to
libpact_ffi.dylib
. So whenever I link against this library (e.g. viago test -c ...
) it looks like this (interestingly linking works ok, not sure which vars control the lookup paths there):(not sure why the version is 0.0.0, looks weird and suspicious, but I've tried two latest libpact_ffi releases and both look like that)
so when
dyld
actually links to it at runtime (and assuming dyld_library_path is not set), it will search by this name first (since it's not absolute path, it'll check current dir) or check fallback path.Search by name fails, because our current work dir is not
/usr/local/lib
and there's no such file. And fallback path is empty by default in my case, I suspect because of the latest MacOS update, so it doesn't even try to search there. This corresponds to the error message I'm seeing, where it only searches current path (and some weird paths that ultimately look like current path + some security nonsense)I was able to resolve it locally by:
DYLD_FALLBACK_LIBRARY_PATH
is set to/usr/local/lib
- tricky to do forgo test
, since it requires using-exec
flag, as described here - https://forum.golangbridge.org/t/go-test-with-cgo-on-macos-and-dyld-library-path/32274/2install_name_tool -id /usr/local/lib/libpact_ffi.dylib /usr/local/lib/libpact_ffi.dylib
- now when linking to this lib, the resulting binary would link to a full path, rather than just the file name, removing the need to search in fallback dirI don't have an older MacOS version to confirm if DYLD_FALLBACK_LIBRARY_PATH was set (or if dyld had a hardcoded value to use when it wasn't set).
I can send a PR to
pact-go
to changeinstall_name_tool
invocation, but I'm not sure why it was setting the name without a full path in the first place, and since I don't fully understand it, I'm worried I might break some use case unknown to me. Could it be that older pact ffi dylibs had a wrong id set and the call toinstall_name_tool
is just to correct it?One more thing that I'm still confused about is how it was supposed to work when custom
--libDir
value was passed to pact-go install - how would that custom library be found without modifying DYLD_* variables or providing a full path ininstall_name_tool
? E.g. in the Makefile of pact-go itself. Is /tmp searched by linker and loader by default?Software versions
go1.20.8
(also tried with go1.21)Relevent log files
pact-go install is successful:
The text was updated successfully, but these errors were encountered: