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
Could not open library 'sodium': dlopen(sodium, 5): image not found. (LoadError) on Apple Silicon M1 #880
Comments
Hello @OleMchls, I think I'm having same issues on my fresh new macbook air m1. I bought it few days ago for my wife and wanted to try if one of my projects will work well natively on ARM without any Rosseta magic. I installed However after I wanted to start If I do !!!! If you open path = ['/usr/lib/','/usr/local/lib/','/opt/local/lib/'].find do |pth|
File.exist?(pth + libname)
end So I ended up with just linking !!! |
also if you happen to have gotten here and upgrading ffi to the fixed version didn't fix your issue, try
|
Some thoughts on this, and seeing many PRs trying to solve it: #965 by @dzprofessionerd, #936 by @southwolf and #941 by @davidperched. The idea of a search path is we should search to find an existing file for which dlopen() succeeds, and keeps trying other paths otherwise. The second thing is why does Homebrew on darwin-aarch64 doesn't add its libraries on the default library search path, such that |
And here is an issue for Homebrew as to why we need to special-case darwin-arm64 and why it does not just work using the system library search path: Homebrew/brew#13481 |
Let's reopen this as it's only solved if there is no Rosetta2 installation, if there is and libraries exist for both arch's it doesn't work. |
* Try every prefix, not just the first one where the file exists. The first existing file might be for the wrong architecture or have other issues and cannot be loaded. * Show which directories were searched in error message. * Only consider /opt/homebrew/lib on darwin-aarch64. * Only rescue LoadError and RuntimeError, not Exception. * Refactor in smaller functions to improve readability. * Fixes ffi#880. * Example error message: Could not open library 'notexist': notexist: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'libnotexist.so': libnotexist.so: cannot open shared object file: No such file or directory. Searched in <system library path>, /usr/lib, /usr/local/lib, /opt/local/lib
I made a PR with a general fix for #880 (comment): #968 |
@here for thoses still waiting on any fix for arm, it seems to work to create a symbolic link from the opt dir of your homebrew prefix to the ffi gem install path. this also solves the problem of if you have a non-standard homebrew path, (which was brought up apparently as a blocker to #968, which I personally think it shouldn't be, lets fix for the majority at least first) ex: ln -sf /opt/homebrew/lib/libsodium.dylib /Users/SampsonCrowley/.rubies/ruby-arm64-2.7.7/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/lib/libsodium.dylib |
Hey there,
I'm trying to get
rbnacl
to function on my M1, but I am hitting the following error message:While at first, this looks like I don't have libsodium installed, I want to point out that I do have it installed via
brew
.But it seems it just does not pick it up. I've started my investigations over here before: RubyCrypto/rbnacl#216
I use asdf which uses ruby-build to build my ruby:
Any pointers or workarounds would be appreciated 👏
The text was updated successfully, but these errors were encountered: