ruby-vips: MacOS Could not open library 'libglib-2.0.dylib': dlopen(libglib-2.0.dylib, 5): image not found

/opt/boxen/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ffi-1.9.18/lib/ffi/library.rb:147:in `block in ffi_lib': Could not open library 'glib-2.0': dlopen(glib-2.0, 5): image not found. (LoadError)
Could not open library 'libglib-2.0.dylib': dlopen(libglib-2.0.dylib, 5): image not found
	from /opt/boxen/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ffi-1.9.18/lib/ffi/library.rb:100:in `map'
	from /opt/boxen/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ffi-1.9.18/lib/ffi/library.rb:100:in `ffi_lib'
	from /opt/boxen/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ruby-vips-2.0.6/lib/vips.rb:28:in `<module:GLib>'
	from /opt/boxen/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ruby-vips-2.0.6/lib/vips.rb:13:in `<top (required)>'
	from ruby_io_speed.rb:1:in `require'
	from ruby_io_speed.rb:1:in `<main>'
rake aborted!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I’m not sure why this isn’t working with Macports but after I manually (yuck) copied the required library to /usr/local/lib, it worked. So, is there something special about /usr/local/lib but not /opt/local/lib?

I just tried on my mac and it all seems to work for me. Here’s what I see. First, brew:

john@katamata ~ $ brew update
Already up-to-date.
john@katamata ~ $ brew install vips
==> Downloading https://homebrew.bintray.com/bottles/vips-8.5.8.sierra.bottle.ta
==> Downloading from https://akamai.bintray.com/6f/6f18a2e5a7cf90c137d809258e5ff
######################################################################## 100.0%
==> Pouring vips-8.5.8.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/vips/8.5.8: 189 files, 12.8MB
john@katamata ~ $ ls /usr/local/lib/libglib*
/usr/local/lib/libglib-2.0.0.dylib /usr/local/lib/libglib-2.0.dylib
/usr/local/lib/libglib-2.0.a
john@katamata ~ $ vips --version
vips-8.5.8-Tue Aug 29 10:02:35 BST 2017

Then Ruby (I’m using the old Apple one):

john@katamata ~ $ which gem
/usr/bin/gem
john@katamata ~ $ which ruby
/usr/bin/ruby
john@katamata ~ $ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
john@katamata ~ $ gem install ruby-vips
Fetching: ffi-1.9.18.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.18
Fetching: ruby-vips-2.0.6.gem (100%)
Successfully installed ruby-vips-2.0.6
Parsing documentation for ffi-1.9.18
Installing ri documentation for ffi-1.9.18
Parsing documentation for ruby-vips-2.0.6
Installing ri documentation for ruby-vips-2.0.6
2 gems installed
john@katamata ~ $ irb
irb(main):001:0> require 'vips'
=> true
irb(main):002:0> x = Vips::Image.black 10, 10
=> #<Image 10x10 uchar, 1 bands, b-w>

So I’d check:

  • you have glib and libvips in /usr/local/lib
  • you can run command-line vips stuff correctly
  • your gem and Ruby know about /usr/local

Looking at @jcupitt 's comments, I went to ffi/ffi#968 and to the forked library. From there, I went to gems/ffi-1.15.5/lib/ffi which is the culprit for me.

Yields a satisfying:

irb
3.1.2 :001 > require 'vips'
 => true 

Yes, this is a hack. But, it looks like there is conversation around a long-term fix, and this gets me through the night.

Facing this error on M1, any quick fix?