0

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.

technion
  • 39
  • 8
  • 1
    I can replicate the error on my Mac OS X (10.11.1)... but I have no idea what you might need in order to start working on a fix. – Myst Dec 01 '15 at 23:00
  • I noticed you don't have a `ext/Rakefile` with a task called `aragon2_wrap` [like the example would show](https://github.com/ffi/ffi-compiler#extrakefile)... Also, I noticed that I have a `libargon2_wrap.so` file in my `ext` folder. I assume it was compiled during the install process... So I'm slightly at a loss as to what might be missing. – Myst Dec 01 '15 at 23:11
  • 1
    P.S. When I compile libraries on my Mac, using Rust, I get the extension `dylib` and not `so`. My `/usr/lib` folder is filled with files with the extensions `o` and `dylib`, never an `so`... it could be that FFI compiled the library but since you forced the output in the `makefile` to an `so` extension, the library name isn't valid on OS X, – Myst Dec 01 '15 at 23:20
  • This is a relevant point. OSX definitely wants different extensions, and I had thought this commit had fixed it: https://github.com/technion/ruby-argon2/commit/b7bf0cf675f45132ab1698176064aa370e271b8e Edit: Would you be able to run "make" from that ext/argon2_wrap folder and watch the commands that get executed? Anything breaking the extension there will be the issue. – technion Dec 01 '15 at 23:23
  • I just installed the gem for the first time, and the makefile I got was pre-commit. It states: `$(CC) $(CFLAGS) $(LIB_CFLAGS) $^ -o libargon2_wrap.so` ... The version I got in the version file is 0.1.1... it was updated 6 days ago on github (your commit is from 5 days ago). The release of the version was on November 26, same day as the commit... maybe the released version doesn't include the fix? – Myst Dec 01 '15 at 23:36
  • @myst the user who reported the issue claimed this commit did not help - which is why I did not tag a new release with that commit. However if it would be possible for you to clone the repo and try the commit from there, it sounds likely it will show us what's wrong. – technion Dec 01 '15 at 23:45
  • The commit wouldn't help him after the installation... since it only applies to the installation process. I have no idea who the user is or what their experience is. For me, the new makefile broke the installation completely... I'm posting the data in an answer. I'll edit the answer as we go along. – Myst Dec 02 '15 at 00:08

1 Answers1

1

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.

Myst
  • 18,516
  • 2
  • 45
  • 67
  • I really can't thank you enough for this assistance. I believe you are looking at a different issue here, related to the local submodule build. You should be able to resolve it by running: `git submodule update --init --recursive` from the repository root directory, before running make. – technion Dec 02 '15 at 00:13
  • Okay, now the install works, the library is compiled... but we're back to square zero. – Myst Dec 02 '15 at 00:35
  • Seems the complied library might not be valid... could it be we need some compile flags? it states `image not found` – Myst Dec 02 '15 at 00:41
  • Regarding compile flags, they are the ones that the official Argon2 library ships with. I'm certainly happy to change them but I don't know what OSX needs that would be different. – technion Dec 02 '15 at 00:47
  • I seem to be finding tonnes of related discussions for OSX: https://github.com/jordansissel/fpm/issues/1010 – technion Dec 02 '15 at 00:57
  • Yeah... I tested two different paths and it seems that the path's content somehow breaks the library loading on FFI. – Myst Dec 02 '15 at 01:16
  • Seems to be a documented issue for MySQL: http://cgarvey.ie/archive/2015/10/01/mysql-client-library-issues-on-os-x-el-capitan/ – technion Dec 02 '15 at 01:20
  • Although it's not "solved", you've identified exactly the upstream issue, so I'll mark as correct. – technion Dec 04 '15 at 00:06
  • Thanks. I just wish we could have actually solved it. – Myst Dec 04 '15 at 00:43