ruby-vips: Mac OS: LoadError: Could not open library 'vips'
So I did brew upgrade vips that poured the vips-8.5.8_2.el_capitan and now require vips (the gem is the latest one) cause:
LoadError: Could not open library 'vips': dlopen(vips, 5): image not found.
Could not open library '/usr/local/lib/libvips.dylib': dlopen(/usr/local/lib/libvips.dylib, 5): Library not loaded: @rpath/libpoppler.71.dylib
Referenced from: /usr/local/opt/poppler/lib/libpoppler-glib.8.dylib
Reason: image not found
from /Users/nakilon/.gem/gems/ffi-1.9.18/lib/ffi/library.rb:147:in `block in ffi_lib'
from /Users/nakilon/.gem/gems/ffi-1.9.18/lib/ffi/library.rb:100:in `map'
from /Users/nakilon/.gem/gems/ffi-1.9.18/lib/ffi/library.rb:100:in `ffi_lib'
from /Users/nakilon/.gem/gems/ruby-vips-2.0.7/lib/vips.rb:466:in `<module:Vips>'
from /Users/nakilon/.gem/gems/ruby-vips-2.0.7/lib/vips.rb:457:in `<top (required)>'
$ ls -l /usr/local/lib/libvips.dylib
lrwxr-xr-x 1 nakilon admin 40 11 окт 19:17 /usr/local/lib/libvips.dylib -> ../Cellar/vips/8.5.8_2/lib/libvips.dylib
$ ls -l /usr/local/lib/libpoppler.dylib
lrwxr-xr-x 1 nakilon admin 45 11 окт 19:17 /usr/local/lib/libpoppler.dylib -> ../Cellar/poppler/0.60.1/lib/libpoppler.dylib
Ruby is native to this OS: 2.0.0p648
The thing I’ve noticed about brew is that now it drags some portable Ruby 2.3 – not sure if that’s relevant.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (19 by maintainers)
Links to this issue
Commits related to this issue
- Fix MacPorts Issue. Could not open library dlopen — committed to comomac/ruby-vips by deleted user 7 years ago
- brew install vips https://github.com/libvips/ruby-vips/issues/141 — committed to shuntagami/dotfiles by shuntagami 9 months ago
This worked for me: Macos M1 Rbenv Ruby 3.0.1 Rails 7.0.1
Just ran
arch -x86_64 brew install vipsand the action_text successfully printed my jpg in trix editor content.For those who don’t know what
arch -x86_64is, take a look at: https://en.wikipedia.org/wiki/Rosetta_(software)So as workaround I’ve decided to copy a
rubyexecutable to another directory – for example, a working directory of where I need to run things. Like this:Here is how I made things work:
IRB
If you do
which irbyou’ll see that it’s a ruby script/usr/bin/irbthat has hardcoded shebang#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyso instead ofirbyou have to do:RSPEC
which rspecgives me/Users/nakilon/.gem/bin/rspecand there we see the#!/usr/bin/env rubythat means you don’t have to patch it, just:RAKE
Running rspec via rake is tricky – it is doing it in another way and seems to use the system ruby. How to check it? The only working way to know the exact path to executable by PID on Mac OS I’ve found is https://stackoverflow.com/a/14805946/322020 so you compile it and put the tool nearby. You can see it’s working by:
Now at the bottom of vips issue backtrace we see
from /Users/nakilon/.gem/gems/rspec-core-3.5.3/exe/rspec:4. Here its content:Right after shebang you add the following line for debug:
Now when you run the rake again you see:
that means shebang is ignored. Open the
/usr/bin/rakeand add theright before the
Rake.application.run– moving down withstepandnextcommands you’ll eventually get to:where the
spec_commandwas:The
RUBYconstant isn’t declared at the moment the byebug starts but it appears immediately after you step intoRake.application.run. If you do theyou’ll find the
RUBY = ENV['RUBY'] || File.join(infile_utils.rbthat is required by/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake.rb. So the solution is:if the default rake task is rspec, and:
for simple custom tasks.
Have a look at #130 and try the suggestions… I think it’s a bad install configuration issue and you need to track down where it went wrong.