libvips / ruby-vips

Ruby extension for the libvips image processing library.
MIT License
829 stars 61 forks source link

Could not open library 'vips.42' #371

Open guschiavon opened 1 year ago

guschiavon commented 1 year ago

Everything was running smoothly until... I ran into this error when running the brew upgrade vips command:

bundle exec jekyll s -l
bundler: failed to load command: jekyll (/Users/gschiavon/.gem/ruby/2.7.3/bin/jekyll)
/Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/dynamic_library.rb:65:in `load_library': Could not open library 'vips.42': dlopen(vips.42, 0x0005): tried: 'vips.42' (no such file), '/System/Volumes/Preboot/Cryptexes/OSvips.42' (no such file), '/usr/lib/vips.42' (no such file, not in dyld cache), 'vips.42' (no such file), '/usr/local/lib/vips.42' (no such file), '/usr/lib/vips.42' (no such file, not in dyld cache). (LoadError)
Could not open library 'libvips.42.dylib': dlopen(libvips.42.dylib, 0x0005): Library not loaded: /opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib
  Referenced from: <555C8E69-E957-3A35-BB01-AF28A62E44B4> /opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache).
Could not open library '/usr/local/lib/libvips.42.dylib': dlopen(/usr/local/lib/libvips.42.dylib, 0x0005): Library not loaded: /opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib
  Referenced from: <555C8E69-E957-3A35-BB01-AF28A62E44B4> /opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache).
Could not open library '/opt/homebrew/lib/libvips.42.dylib': dlopen(/opt/homebrew/lib/libvips.42.dylib, 0x0005): Library not loaded: /opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib
  Referenced from: <555C8E69-E957-3A35-BB01-AF28A62E44B4> /opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file, not in dyld cache).
Searched in <system library path>, /usr/lib, /usr/local/lib, /opt/local/lib, /opt/homebrew/lib
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/library.rb:95:in `block in ffi_lib'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/library.rb:94:in `map'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/library.rb:94:in `ffi_lib'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ruby-vips-2.0.17/lib/vips.rb:528:in `<module:Vips>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ruby-vips-2.0.17/lib/vips.rb:525:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ruby-vips-2.0.17/lib/ruby-vips.rb:1:in `require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/ruby-vips-2.0.17/lib/ruby-vips.rb:1:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag/images/generated_image.rb:1:in `require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag/images/generated_image.rb:1:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag/images.rb:2:in `require_relative'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag/images.rb:2:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag.rb:5:in `require_relative'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll_picture_tag-2.0.4/lib/jekyll_picture_tag.rb:5:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:60:in `require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:55:in `each'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:55:in `block in require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:44:in `each'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/runtime.rb:44:in `require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler.rb:176:in `require'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll-4.3.2/lib/jekyll/plugin_manager.rb:53:in `require_from_bundler'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/jekyll-4.3.2/exe/jekyll:11:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/bin/jekyll:25:in `load'
        from /Users/gschiavon/.gem/ruby/2.7.3/bin/jekyll:25:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli/exec.rb:58:in `load'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli/exec.rb:23:in `run'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli.rb:484:in `exec'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli.rb:31:in `dispatch'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/cli.rb:25:in `start'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/exe/bundle:48:in `block in <top (required)>'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /Users/gschiavon/.gem/ruby/2.7.3/gems/bundler-2.3.6/exe/bundle:36:in `<top (required)>'
        from /Users/gschiavon/.gem/ruby/3.0.0/bin/bundle:23:in `load'
        from /Users/gschiavon/.gem/ruby/3.0.0/bin/bundle:23:in `<main>'

From what I understand there is a misconfigured path to the library vips.42 but upon checking the folder, it indeed doesn't exist.

Which VIPS

/opt/homebrew/bin/vips

Ruby -v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]

System

MacBookPro M1 OSX Ventura 13.4

I can provide more config info as required. 🙏 someone can help!

jcupitt commented 1 year ago

I'll have a go on my mac mini tomorrow.

jcupitt commented 1 year ago

Hi again, I tried here and it all seems to work for me.

Looking at your log, I think you have several rubys installed and they are all mixed up:

$ bundle exec jekyll s -l
bundler: failed to load command: jekyll (/Users/gschiavon/.gem/ruby/2.7.3/bin/jekyll)
/Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/dynamic_library.rb:65:in ...

I don't know what 2.7.3 is doing here. macOS ships with 2.6.10, so maybe this is a very old homebrew version? Homebrew is currently on 3.2.2. You say you're trying to use ruby 3.0.2, but that's another version again.

I'd pick a ruby and make sure you have the matching version of gem. Check your environment variables, and especially check PATH. Wipe your .gem directory and reinstall everything. Check gem show ruby-vips and make sure it looks sensible.

I see:

john@cheese ~ $ which irb
/opt/homebrew/Cellar/ruby/3.2.2_1/bin/irb
john@cheese ~ $ which ruby
/opt/homebrew/Cellar/ruby/3.2.2_1/bin/ruby
john@cheese ~ $ which gem
/opt/homebrew/Cellar/ruby/3.2.2_1/bin/gem
john@cheese ~ $ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
john@cheese ~ $ gem info ruby-vips

*** LOCAL GEMS ***

ruby-vips (2.1.4)
    Author: John Cupitt
    Homepage: http://github.com/libvips/ruby-vips
    License: MIT
    Installed at: /opt/homebrew/lib/ruby/gems/3.2.0

    A fast image processing library with low memory needs
john@cheese ~ $ which vips
/opt/homebrew/bin/vips
john@cheese ~ $ vips --version
vips-8.14.5
john@cheese ~ $ irb
irb(main):001:0> require "vips"
=> true
irb(main):002:0> 
guschiavon commented 1 year ago

Hey John thank you so much for taking the time to write up and explain; I’m not a Ruby developer although I do use Jekyll for a lot of projects, and honestly the gem environment is a bit alien to me.

Since writing up the issue I’ve made some updates and managed to make it all work; it indeed involved wiping out all of the gems, installing “rbenv”, reinstalling Ruby (using 3.0.2 now) and then reinstalling all gems, rehashing and who knows what else! I’ve prompted ChatGPT to help me out and a lot of the advice it gave was very helpful.

Here’s what I get running the same commands:

➜ ~ which ruby /Users/gschiavon/.rbenv/shims/ruby ➜ ~ which gem /Users/gschiavon/.rbenv/shims/gem ➜ ~ ruby -v ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin22] ➜ ~ gem info ruby-vips

LOCAL GEMS

ruby-vips (2.0.17) Author: John Cupitt Homepage: http://github.com/libvips/ruby-vips License: MIT Installed at: /Users/gschiavon/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0

Ruby extension for the vips image processing library.

➜ ~ which vips /opt/homebrew/bin/vips ➜ ~ vips -v vips-8.14.5

And echoing the path: /Users/gschiavon/.gem/ruby/3.0.0/bin:/opt/homebrew/opt/ruby/bin:/Users/gschiavon/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

I confess I’m a bit scared to make any changes now that all is back working but I’m open to your comments and recommendations!

Best regards, Gus

On 26 Sep 2023, at 07:14, John Cupitt @.***> wrote:

Hi again, I tried here and it all seems to work for me.

Looking at your log, I think you have several rubys installed and they are all mixed up:

$ bundle exec jekyll s -l bundler: failed to load command: jekyll (/Users/gschiavon/.gem/ruby/2.7.3/bin/jekyll) /Users/gschiavon/.gem/ruby/2.7.3/gems/ffi-1.16.1/lib/ffi/dynamic_library.rb:65:in ... I don't know what 2.7.3 is doing here. macOS ships with 2.6.10, so maybe this is a very old homebrew version? Homebrew is currently on 3.2.2. You say you're trying to use ruby 3.0.2, but that's another version again.

I'd pick a ruby and make sure you have the matching version of gem. Check your environment variables, and especially check PATH. Wipe your .gem directory and reinstall everything. Check gem show ruby-vips and make sure it looks sensible.

I see:

@. ~ $ which irb /opt/homebrew/Cellar/ruby/3.2.2_1/bin/irb @. ~ $ which ruby /opt/homebrew/Cellar/ruby/3.2.2_1/bin/ruby @. ~ $ which gem /opt/homebrew/Cellar/ruby/3.2.2_1/bin/gem @. ~ $ ruby --version ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22] @.*** ~ $ gem info ruby-vips

LOCAL GEMS

ruby-vips (2.1.4) Author: John Cupitt Homepage: http://github.com/libvips/ruby-vips License: MIT Installed at: /opt/homebrew/lib/ruby/gems/3.2.0

A fast image processing library with low memory needs

@. ~ $ which vips /opt/homebrew/bin/vips @. ~ $ vips --version vips-8.14.5 @.*** ~ $ irb irb(main):001:0> require "vips" => true irb(main):002:0> — Reply to this email directly, view it on GitHub https://github.com/libvips/ruby-vips/issues/371#issuecomment-1735242373, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO4KHZFQPEPW5MWB6SOMDLX4KTHLANCNFSM6AAAAAA5GQIHMI. You are receiving this because you authored the thread.

jcupitt commented 1 year ago

Hi Gus, sure, looks reasonable.

villu164 commented 1 year ago

I also ran into this issue yesterday (likely because homebrew updated bunch of stuff) Anyway, the

vips --version

which blew up for me

vips --version      
dyld[5853]: Library not loaded: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib'
  Referenced from: '/opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib'
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file)
[1]    5853 abort      vips --version

was very helpful, because I was able to take the ruby out of the issue chain

I removed hdf5

brew uninstall hdf5   
Error: Refusing to uninstall /opt/homebrew/Cellar/hdf5/1.14.2
because it is required by libmatio and vips, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies hdf5

which at forst refused, but

brew uninstall libmatio vips
Uninstalling /opt/homebrew/Cellar/libmatio/1.5.23... (38 files, 974.2KB)
Uninstalling /opt/homebrew/Cellar/vips/8.14.5... (84 files, 5.7MB)

brew uninstall hdf5         
Uninstalling /opt/homebrew/Cellar/hdf5/1.14.2... (285 files, 21MB)

brew install vips  
...

was almost there, but complained some errors

vips --version

(process:6825): VIPS-WARNING **: 22:55:08.731: unable to load "/opt/homebrew/Cellar/vips/8.14.5/lib/vips-modules-8.14/vips-openslide.so" -- dlopen(/opt/homebrew/Cellar/vips/8.14.5/lib/vips-modules-8.14/vips-openslide.so, 0x0009): Library not loaded: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib'
  Referenced from: '/opt/homebrew/Cellar/openslide/3.4.1_7/lib/libopenslide.0.dylib'
  Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file)
vips-8.14.5

making some other guesses

brew install openslide

and got rid of the error

vips --version        

vips-8.14.5

So likely some dependency chain issue from homebrew 🤷

imtrent commented 1 year ago

I also ran into this issue yesterday (likely because homebrew updated bunch of stuff) Anyway, the

vips --version

which blew up for me

vips --version      
dyld[5853]: Library not loaded: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib'
  Referenced from: '/opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib'
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file), '/opt/homebrew/Cellar/hdf5/1.14.2/lib/libhdf5.200.dylib' (no such file), '/usr/local/lib/libhdf5.200.dylib' (no such file), '/usr/lib/libhdf5.200.dylib' (no such file)
[1]    5853 abort      vips --version

was very helpful, because I was able to take the ruby out of the issue chain

I removed hdf5

brew uninstall hdf5   
Error: Refusing to uninstall /opt/homebrew/Cellar/hdf5/1.14.2
because it is required by libmatio and vips, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies hdf5

which at forst refused, but

brew uninstall libmatio vips
Uninstalling /opt/homebrew/Cellar/libmatio/1.5.23... (38 files, 974.2KB)
Uninstalling /opt/homebrew/Cellar/vips/8.14.5... (84 files, 5.7MB)

brew uninstall hdf5         
Uninstalling /opt/homebrew/Cellar/hdf5/1.14.2... (285 files, 21MB)

brew install vips  
...

was almost there, but complained some errors

vips --version

(process:6825): VIPS-WARNING **: 22:55:08.731: unable to load "/opt/homebrew/Cellar/vips/8.14.5/lib/vips-modules-8.14/vips-openslide.so" -- dlopen(/opt/homebrew/Cellar/vips/8.14.5/lib/vips-modules-8.14/vips-openslide.so, 0x0009): Library not loaded: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib'
  Referenced from: '/opt/homebrew/Cellar/openslide/3.4.1_7/lib/libopenslide.0.dylib'
  Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file)
vips-8.14.5

making some other guesses

brew install openslide

and got rid of the error

vips --version        

vips-8.14.5

So likely some dependency chain issue from homebrew 🤷

So glad I came across this. Thanks for sharing how you fixed it! Worked for me as well

solidiquis commented 1 year ago

@villu164's is the correct solution imo, but if for whatever reason you can't update vips' dependencies for whatever reason, you can also just create a soft link whose name is the version of hdf5 this gem is expecting. Example, if your error says this:

 Referenced from: <555C8E69-E957-3A35-BB01-AF28A62E44B4> /opt/homebrew/Cellar/libmatio/1.5.23/lib/libmatio.11.dylib
  Reason: tried: '/opt/homebrew/opt/hdf5/lib/libhdf5.200.dylib' (no such file),

and lets say in your /opt/homebrew/opt/hdf5/lib/ directory you have libhdf5.310.dylib, then all you'll need to do is:

ln -s libhdf5.310.dylib libhdf5.200.dylib