-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix MacPorts Issue. Could not open library dlopen #144
Conversation
Hello @comomac, thank you for this patch. I've been trying to read around this issue, and it seems to be something that's causing problems for quite a few people, for example: It seems we need to search for our libraries on macOS, especially if SIP is enabled. This is very annoying! We need to try:
What do you think? We need to add this extra search to |
Did some quick reading. I didn't have to disable SIP because my environment didn't need it yet (MacPorts). But it does seems like
I've tried to find out if there is a in-built method (Ruby and FFI) to have an list of library path to search in order like environment PATH variable in shell but for library, but came out empty. I've thinking that if we could fix path issue, it will solve majority of user's problem (there are probably a lot people experience it but didn't report) when they first tried using the library. If path issue isn't fixed this round, we will fix it next round and learn more from experience and hopefully find out the best way to solve path search issue. Or maybe FFI project may just come up with path search instead (laugh). |
@comomac have you tried to recheck your problems on High Sierra? |
One option to fix this is to compile glib directly into the gem. I started working on something like that here: https://github.com/ioquatix/vips but for now it only compiles |
Forgot to check message. I'm running Sierra so I don't know if the problem persist in High Sierra. |
syncing from upstream
I came across this in the ruby ffi sources: https://github.com/ffi/ffi/blob/master/lib/ffi/library.rb#L127 # TODO better library lookup logic
unless libname.start_with?("/") || FFI::Platform.windows?
path = ['/usr/lib/','/usr/local/lib/'].find do |pth| Perhaps everyone knows about this. Anyway, it seems that:
The best solution would probably be for ruby-ffi to have its own dyld path on macOS (on Windows there's RUBY_DLL_PATH, I believe). Failing that, ruby-vips probably needs a very ugly magic search hack :-( |
@jcupitt Thanks, I was looking for answer on FFI |
Just a reminder: my High Sierra doesn't have the issue. You might want to upgrade because old system Ruby (2.0) is with an old OpenSSL that makes it unusable in some scenarios (and maybe this is why brew now downloads Ruby for itself -- just a guess). |
@comomac sure, PR away! I have loads of work this weekend :( I'm sure they'd have expert insights, even if this change is not quite correct. @Nakilon my High Sierra machine has this issue, or at least a variant of it. If I use the Apple Ruby and install libvips to a non-standard prefix, I can't get ruby-ffi to open my libvips.dylib without giving the exact path in the dlopen() line. |
Oh I missed this point. |
close. the path is added to ffi/ffi#638 master branch |
Thanks @comomac ! Nice work. |
Thanks for this! |
I had issue trying to load the library, which is caused by looking at wrong place for library.
My setup is using MacPorts which may be the cause. I've setup to auto detect the environment (macos) and if the library exist, will use the fullpath of the library.