ankane / argon2-kdf

Argon2 key derivation for Ruby
MIT License
8 stars 2 forks source link

libargon2.so shared object file not found even if the file exists #5

Closed mzanini closed 3 years ago

mzanini commented 3 years ago

I am using blind_index gem to enforce uniqueness of the email field on the users table but it seems like blind_index cannot find the shared object file even if the file is there, any idea on how to fix this?

Here is the error:

irb(main):008:0> user = User.create(email: 'marco@example.com')
Traceback (most recent call last):
        1: from (irb):8
Fiddle::DLError (/usr/local/bundle/gems/argon2-kdf-0.1.5/vendor/libargon2.so: cannot open shared object file: No such file or directory)

But the file is there:

irb(main):009:0> Dir.entries('/usr/local/bundle/gems/argon2-kdf-0.1.5/vendor')
=> ["LICENSE", "..", "libargon2.dylib", "argon2.dll", "libargon2.so", ".", "libargon2.arm64.dylib"]

Also, I have access to it (also tried to touch it and it works):

marco@3846cfe592f3:/app$ ls -l /usr/local/bundle/gems/argon2-kdf-0.1.5/vendor/
total 396
-rw-r--r-- 1 marco marco  17879 Mar  9 15:03 LICENSE
-rw-r--r-- 1 marco marco  32768 Mar  9 15:03 argon2.dll
-rw-r--r-- 1 marco marco  87486 Mar  9 15:03 libargon2.arm64.dylib
-rw-r--r-- 1 marco marco  46340 Mar  9 15:03 libargon2.dylib
-rw-r--r-- 1 marco marco 212664 Mar  9 15:08 libargon2.so

I am developing in Docker, my container is the standard ruby:2.7.1. Some more details:

irb(main):010:0> RbConfig::CONFIG["arch"]
=> "aarch64-linux"
irb(main):011:0> RbConfig::CONFIG["host_cpu"]
=> "aarch64"
irb(main):012:0> Gem::Platform.local
=> #<Gem::Platform:0x0000aaab1ad90f38 @cpu="aarch64", @os="linux", @version=nil @cpu="aarch64", @os="linux", @version=nil>
irb(main):013:0> Gem::Platform.local.to_s
=> "aarch64-linux"

Thank you for all the help and your wonderful gems @ankane!

EDIT: This could be because I am on a Mac M1?

ankane commented 3 years ago

Hey @mzanini, the gem doesn't currently ship with a shared library for ARM on Linux. I was able to cross-compile one on GitHub Actions (code), but could use some help testing it. Can you download the build artifact and in an intializer, set:

Argon2::KDF.ffi_lib = "path/to/downloaded/libargon2.so"

If that works, can add it to the gem.

mzanini commented 3 years ago

Thank you @ankane, it seems to work! Do you want me to keep an eye out for something?

ankane commented 3 years ago

Great, thanks @mzanini! If you're not seeing errors, it should be good. Just pushed a new release that includes it.