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

Gem Load Error is: wrong constant name 3D #1124

Closed
ollym opened this issue Jan 10, 2018 · 24 comments
Closed

Gem Load Error is: wrong constant name 3D #1124

ollym opened this issue Jan 10, 2018 · 24 comments

Comments

@ollym
Copy link

ollym commented Jan 10, 2018

Ruby 2.4.1

this is using the poppler gem 3.2.1

Gem Load Error is: wrong constant name 3D
Backtrace for gem load error is:
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `const_set'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `load_enum_value'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:187:in `block in load_enum_info'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `load_enum_info'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler/loader.rb:57:in `load_enum_info'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:66:in `load_info'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:43:in `block in load'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:34:in `block (2 levels) in each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `times'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `block in each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:42:in `load'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:35:in `<module:Poppler>'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:30:in `<top (required)>'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:82:in `require'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:in `each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:in `block in require'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:in `each'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:in `require'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler.rb:108:in `require'
/Users/ollym/GitHub/ventrata/cityconnect/config/application.rb:8:in `<top (required)>'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `require'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `block in perform'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
@kou
Copy link
Member

kou commented Jan 11, 2018

Can you show your Poppler (not poppler gem) version?

@ollym
Copy link
Author

ollym commented Jan 11, 2018

@kou hey sure, it's Poppler 0.62.0 installed on OSX by homebrew.

@kou
Copy link
Member

kou commented Jan 12, 2018

Thanks.
Can you show the output of ruby -v -rpopper -e '' with the following change:

diff --git a/poppler/lib/poppler/loader.rb b/poppler/lib/poppler/loader.rb
index d7ded8625..ed91b9398 100644
--- a/poppler/lib/poppler/loader.rb
+++ b/poppler/lib/poppler/loader.rb
@@ -43,6 +43,7 @@ module Poppler
     end
 
     def load_enum_info(info)
+      p [info.name, info.values.collect(&:name)]
       case info.name
       when "AnnotType"
         self.class.register_constant_rename_map("3D", "TYPE_3D")

@meetajhu
Copy link

Even i'm facing the same issue. Unable to start Rails server unless i comment out poppler and cairo-gobject in Gemfile.

@kou
Copy link
Member

kou commented Jan 15, 2018

Can you show your environment?

@ollym
Copy link
Author

ollym commented Jan 15, 2018

@kou sorry for the delay, small typo in your command ruby -v -rpoppler -e '' missed an l !

Anyway, here's the output you're after:

Olivers-MacBook-Pro-2:~ ollym$ ruby -v -rpoppler -e ''
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
(null)-WARNING **: Failed to load shared library '@rpath/libpoppler-glib.8.dylib' referenced by the typelib: dlopen(@rpath/libpoppler-glib.8.dylib, 9): image not found
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:629:in `load_union_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:74:in `load_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:43:in `block in load'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:34:in `block (2 levels) in each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `times'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `block in each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:42:in `load'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:35:in `<module:Poppler>'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:30:in `<top (required)>'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
["ActionLayerAction", ["on", "off", "toggle"]]
["ActionMovieOperation", ["play", "pause", "resume", "stop"]]
["ActionType", ["unknown", "none", "goto_dest", "goto_remote", "launch", "uri", "named", "movie", "rendition", "ocg_state", "javascript"]]
["AnnotExternalDataType", ["3d", "unknown"]]
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `const_set': wrong constant name 3D (NameError)
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `load_enum_value'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:187:in `block in load_enum_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `load_enum_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler/loader.rb:58:in `load_enum_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:66:in `load_info'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:43:in `block in load'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:34:in `block (2 levels) in each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `times'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `block in each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:42:in `load'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:35:in `<module:Poppler>'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:30:in `<top (required)>'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'

@kou
Copy link
Member

kou commented Jan 15, 2018

Can you fix the warning?

(null)-WARNING **: Failed to load shared library '@rpath/libpoppler-glib.8.dylib' referenced by the typelib: dlopen(@rpath/libpoppler-glib.8.dylib, 9): image not found

You may need to add /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/ to DYLD_LIBRARY_PATH.

@ollym
Copy link
Author

ollym commented Jan 15, 2018

poppler was installed using homebrew, the path to that file is: /usr/local/lib/libpoppler-glib.8.dylib

$ file /usr/local/lib/libpoppler-glib.8.dylib
/usr/local/lib/libpoppler-glib.8.dylib: Mach-O 64-bit dynamically linked shared library x86_64

What is @rpath and why isn't that looking in /usr/local/lib/ for this file?

@kou
Copy link
Member

kou commented Jan 15, 2018

I'm not a macOS user. Can you look into it?

@meetajhu
Copy link

meetajhu commented Jan 16, 2018

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
(null)-WARNING **: Failed to load shared library '@rpath/libpoppler-glib.8.dylib' referenced by the typelib: dlopen(@rpath/libpoppler-glib.8.dylib, 9): image not found
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:629:in `load_union_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:74:in `load_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:43:in `block in load'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:34:in `block (2 levels) in each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `times'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `block in each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:42:in `load'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:35:in `<module:Poppler>'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:30:in `<top (required)>'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `const_set': wrong constant name 3D (NameError)
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:162:in `load_enum_value'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:187:in `block in load_enum_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:186:in `load_enum_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler/loader.rb:57:in `load_enum_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:66:in `load_info'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:43:in `block in load'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:34:in `block (2 levels) in each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `times'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:33:in `block in each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/repository.rb:32:in `each'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/gobject-introspection-3.2.1/lib/gobject-introspection/loader.rb:42:in `load'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:35:in `<module:Poppler>'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/poppler-3.2.1/lib/poppler.rb:30:in `<top (required)>'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
	from /Users/BigBoss/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'```

@kou
Copy link
Member

kou commented Jan 16, 2018

I think that it's a problem of Homebrew. Can you report it to Homebrew?

The output of the followings may help Homebrew developers:

% ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler.dylib")'
% DYLD_LIBRARY_PATH=/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/:$(brew --prefix)/lib ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler.dylib")'

@ollym
Copy link
Author

ollym commented Jan 16, 2018

@kou that command you wrote there works great:

$ ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler.dylib")'
#<Fiddle::Handle:0x007f9e95a171e8>

@kou
Copy link
Member

kou commented Jan 16, 2018

What about this?

% ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler-glib.dylib")'

Again, I'm not a macOS user. We need your help. Can you try to look into this problem?

@ollym
Copy link
Author

ollym commented Jan 18, 2018

Yea honestly I'm not sure what I'm meant to be looking for.

$ ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler-glib.dylib")'
#<Fiddle::Handle:0x007f87ec19aef8>

@ollym
Copy link
Author

ollym commented Jan 18, 2018

$ ruby -r fiddle -e 'p Fiddle.dlopen("libpoppler-glib.8.dylib")'
#<Fiddle::Handle:0x007fca5da0f288>

works too

@kou
Copy link
Member

kou commented Jan 18, 2018

% ruby -r fiddle -e 'p Fiddle.dlopen("@rpath/libpoppler-glib.8.dylib")'
% strings $(brew --prefix)/lib/girepository-1.0/*.typelib | grep dylib

@meetajhu
Copy link

meetajhu commented Jan 18, 2018

Hi @kou

I did post a issue at homebrew. They seem to say its a problem with rbenv. Let me go through in fixing the path myself to find out what happened.

@ollym
Copy link
Author

ollym commented Jan 18, 2018

$ ruby -r fiddle -e 'p Fiddle.dlopen("@rpath/libpoppler-glib.8.dylib")'
/Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/fiddle.rb:47:in `initialize': dlopen(@rpath/libpoppler-glib.8.dylib, 9): image not found (Fiddle::DLError)
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/fiddle.rb:47:in `new'
	from /Users/ollym/.rbenv/versions/2.4.1/lib/ruby/2.4.0/fiddle.rb:47:in `dlopen'
	from -e:1:in `<main>'
$ strings $(brew --prefix)/lib/girepository-1.0/*.typelib | grep dylib
/usr/local/Cellar/gobject-introspection/1.54.1/lib/libgirepository-1.0.1.dylib
/usr/local/opt/glib/lib/libglib-2.0.0.dylib,/usr/local/opt/glib/lib/libgobject-2.0.0.dylib
/usr/local/opt/glib/lib/libgmodule-2.0.0.dylib
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib
/usr/local/opt/glib/lib/libgio-2.0.0.dylib
/usr/local/Cellar/harfbuzz/1.7.4/lib/libharfbuzz.0.dylib,/usr/local/Cellar/harfbuzz/1.7.4/lib/libharfbuzz-gobject.0.dylib
/usr/local/Cellar/pango/1.40.14/lib/libpango-1.0.0.dylib
/usr/local/Cellar/pango/1.40.14/lib/libpango-1.0.0.dylib,/usr/local/Cellar/pango/1.40.14/lib/libpangocairo-1.0.0.dylib,/usr/local/Cellar/pango/1.40.14/lib/libpango-1.0.0.dylib,/usr/local/Cellar/pango/1.40.14/lib/libpangoft2-1.0.0.dylib
/usr/local/Cellar/pango/1.40.14/lib/libpango-1.0.0.dylib,/usr/local/Cellar/pango/1.40.14/lib/libpangoft2-1.0.0.dylib
@rpath/libpoppler-glib.8.dylib
libcairo-gobject.2.dylib

@kou
Copy link
Member

kou commented Jan 19, 2018

@meetajhu Great!

@kou
Copy link
Member

kou commented Jan 19, 2018

@ollym It seems that Poppler's typelib file only uses @rpath. It may be a problem of Homebrew's build option or Poppler GLib's build system: https://cgit.freedesktop.org/poppler/poppler/tree/glib/CMakeLists.txt

@kou
Copy link
Member

kou commented Jan 22, 2018

This poppler formula change will help you. This change resolves @rpath in .typelib. We should send feedback to both Poppler and Homebrew to find a suitable solution on macOS.

diff --git a/Formula/poppler.rb b/Formula/poppler.rb
index 1b446ea0fa..42b3cc53e0 100644
--- a/Formula/poppler.rb
+++ b/Formula/poppler.rb
@@ -68,6 +68,18 @@ class Poppler < Formula
     end
 
     system "cmake", ".", *args
+    system "make"
+    Dir.glob("glib/*.gir") do |gir_path|
+      gir_content = File.read(gir_path).gsub(/(shared-library=".+?")/) do
+        $1.gsub(/@rpath/) {lib}
+      end
+      File.open(gir_path, "w") do |gir_file|
+        gir_file.print(gir_content)
+      end
+    end
+    Dir.glob("glib/*.typelib") do |typelib_path|
+      rm_f(typelib_path)
+    end
     system "make", "install"
     resource("font-data").stage do
       system "make", "install", "prefix=#{prefix}"

@cosmo0920
Copy link
Member

Generally speaking, Homebrew won't accept patches without upstream feedback.
I think that we should report this issue in poppler first, then we can introduce the above patch into Homebrew-core.

@kou
Copy link
Member

kou commented Jun 18, 2018

Workaround:

% DYLD_LIBRARY_PATH=$(brew --prefix poppler)/lib ruby ...

Anyway, we should work together to fix the problem on Homebrew and Poppler.

znz added a commit to znz/dot-shell that referenced this issue Oct 4, 2018
@kou
Copy link
Member

kou commented Sep 8, 2019

This has been solved in the latest Homebrew and Poppler.

@kou kou closed this as completed Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants