Skip to content
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 'libglib-2.0.so.0.so' #212

Closed
linkyndy opened this issue Nov 8, 2019 · 11 comments
Closed

Could not open library 'libglib-2.0.so.0.so' #212

linkyndy opened this issue Nov 8, 2019 · 11 comments

Comments

@linkyndy
Copy link
Contributor

linkyndy commented Nov 8, 2019

Hello,

I've tried using the 2.0.16 version of this gem on Ruby 2.5.5 (combined with libvips 8.8.3 on an Alpine Docker container, if it helps) and I get the following error:

Traceback (most recent call last):
	24: from /usr/local/bin/bundle:22:in `<main>'
	23: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
	22: from /usr/local/bin/bundle:30:in `block in <main>'
	21: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:18:in `start'
	20: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
	19: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:27:in `dispatch'
	18: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
	17: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
	16: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	15: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:494:in `console'
	14: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli/console.rb:15:in `run'
	13: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `require'
	12: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `require'
	11: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `each'
	10: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `block in require'
	 9: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `each'
	 8: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `block (2 levels) in require'
	 7: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `require'
	 6: from /app/vendor/bundle/ruby/2.5.0/gems/ruby-vips-2.0.16/lib/ruby-vips.rb:1:in `<top (required)>'
	 5: from /app/vendor/bundle/ruby/2.5.0/gems/ruby-vips-2.0.16/lib/ruby-vips.rb:1:in `require'
	 4: from /app/vendor/bundle/ruby/2.5.0/gems/ruby-vips-2.0.16/lib/vips.rb:36:in `<top (required)>'
	 3: from /app/vendor/bundle/ruby/2.5.0/gems/ruby-vips-2.0.16/lib/vips.rb:45:in `<module:GLib>'
	 2: from /app/vendor/bundle/ruby/2.5.0/gems/ffi-1.11.1/lib/ffi/library.rb:99:in `ffi_lib'
	 1: from /app/vendor/bundle/ruby/2.5.0/gems/ffi-1.11.1/lib/ffi/library.rb:99:in `map'
/app/vendor/bundle/ruby/2.5.0/gems/ffi-1.11.1/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'glib-2.0.so.0': Error loading shared library glib-2.0.so.0: No such file or directory. (LoadError)
Could not open library 'libglib-2.0.so.0.so': Error loading shared library libglib-2.0.so.0.so: No such file or directory

I assume it has to do with the latest changes with regards to generating libnames.

@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

Hello @linkyndy,

Well, that looks bad: libglib-2.0.so.0.so

I'll see if I can reproduce the problem in a docker container.

@jcupitt jcupitt added the bug label Nov 8, 2019
@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

Yes, I see this in a container as well:

https://github.com/jcupitt/docker-builds/blob/master/ruby-vips-alpine/Dockerfile

Here's what seems to be happening:

  • ruby-vips wants to open library glib-2.0, API number 0
  • on linux, ruby-vips library_name turns this into glib-2.0.so.0
  • ffi_lib calls map_library_name to turn this into a platform native name
  • this adds a lib prefix to make libglib-2.0.so.0 (the correct name)
  • map_library_name then incorrectly adds an extra .so suffix if FFI::Platform::IS_GNU is not true

https://github.com/ffi/ffi/blob/master/lib/ffi/library.rb#L50

So it looks like Alpine is not GNU enough for ffi, I think. Looking at IS_GNU it's:

https://github.com/ffi/ffi/blob/master/lib/ffi/platform.rb#L91

    IS_GNU = defined?(GNU_LIBC)

So I think this is a Ruby ffi bug: they should not add that extra suffix on Alpine.

@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

What do you think @linkyndy? We could try opening an issue on ruby ffi. Perhaps they need an IS_MUSL?

@linkyndy
Copy link
Contributor Author

linkyndy commented Nov 8, 2019

I tested with both 2.0.15 and 2.0.16 of this gem, using the same setup, and everything is fine with the former. That's why I stopped my investigation here and didn't go to FFI. If you checked more things (thanks for that!) and feel it belongs to FFI, sure, I can pass this along.

@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

I think it only worked on Alpine with ruby-vips 2.0.15 if you had the glib-dev package installed.

Without that package, there's no libglib-2.0.so link, and it would have failed to find the library.

@linkyndy
Copy link
Contributor Author

linkyndy commented Nov 8, 2019

Both gem versions were tested with the following installed on an Alpine container:

RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ \
  build-base \
  curl-dev \
  nano \
  libffi-dev \
  vips-dev

So, I would assume the dependencies were the same 🤔

@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

vips-dev will have pulled in glib-dev. If you try with just vips I think it'll fail (I think).

@jcupitt
Copy link
Member

jcupitt commented Nov 8, 2019

I made an issue here: ffi/ffi#727

@linkyndy
Copy link
Contributor Author

Thanks a lot @jcupitt for your very quick action! Looking forward to this being resolved 😊

@jcupitt
Copy link
Member

jcupitt commented Nov 11, 2019

The very helpful @larskanis has changed ffi to hopefully fix this.

I'll close -- please open a new issue if you run into more problems.

@jcupitt jcupitt closed this as completed Nov 11, 2019
@larskanis
Copy link
Contributor

ffi-1.11.2 should fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants