执行brew upgrade vips后Ruby/Jekyll无法打开vips.42库求助
问题描述
此前一切运行正常,执行brew upgrade vips命令后,运行bundle exec jekyll s -l时出现加载错误,推测是vips.42库路径问题,但检查对应文件夹后发现该文件确实不存在。
错误日志
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>'
环境信息
- VIPS路径:
/opt/homebrew/bin/vips - Ruby版本:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20] - 系统环境:MacBookPro M1,OSX Ventura 13.4
解决方案
核心原因
错误日志显示,libvips.42.dylib本身存在,但它依赖的libmatio找不到旧版本的libhdf5.200.dylib——brew升级vips时,hdf5被更新到更高版本,旧版本库被移除,而libmatio没有重新编译链接到新的hdf5库。
修复步骤
- 重新安装
libmatio,让它重新链接当前系统中的hdf5版本:brew reinstall libmatio - 重新安装vips,确保所有依赖链正确关联:
brew reinstall vips - 重新安装Ruby依赖,让bundler识别最新的vips库:
bundle install - 再次测试Jekyll启动命令:
bundle exec jekyll s -l
额外排查
- 日志中使用的Ruby版本是2.7.3,但当前环境是3.0.2,若上述步骤无效,检查bundler绑定的Ruby版本:
若版本不匹配,切换到正确的Ruby版本后重新执行bundle envbundle install。
内容的提问来源于stack exchange,提问作者gschiavon
相关产品推荐
相关产品推荐

