technion
technion

Reputation: 49

Ruby FFI loading - OSX

I'm wondering if someone can assist with the issue that has been opened here:

https://github.com/technion/ruby-argon2/issues/1

Specifically, I have released a gem, and I've received advise a user is experiencing an issue. That being the following error when loading my gem:

LoadError: cannot find 'argon2_wrap' library
from /Users/me/.rvm/gems/ruby-2.2.1/gems/ffi-compiler-0.1.3/lib/ffi-compiler/loader.rb:21:in `find'

I'm considering it extremely likely to be an OSX issue, as I've done my damndest to replicate this and had no success. And the error basically shows what happens on my Linux machine if I don't actually compile the shared library. I do not however have a Mac available, and therefore any ability to test this.

I really want to take supporting this gem seriously and anyone who can give me some pointers would be really appreciated.

Upvotes: 0

Views: 758

Answers (1)

Myst
Myst

Reputation: 19221

Success!!! :-(

Why a sad face? because it IS an FFI issue and I have no idea how to go around it.

It seems the naming of the path causes the FFI library loading to fail on OS X.

I Tried this:

require 'ffi'
module Hello
    extend FFI::Library
    ffi_lib "Users/USERNAME/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/argon2-0.1.1/ext/argon2_wrap/libargon2_wrap.dylib"
end
 # => FAILS to load library

I copied the compiled library to my desktop and loaded it using FFI and a clean path:

require 'ffi'
module Hello
    extend FFI::Library
    ffi_lib "/Users/USERNAME/Desktop/libargon2_wrap.dylib"
end
# => Success, the library loaded

Now we know where the issue comes from and we might be able to help resolve the issue with the FFI library.

Edit

I would (I'm sorry to say) attempt porting the FFI to Ruby's core fiddle library. You can see a Fiddle tutorial here.

Upvotes: 1

Related Questions