ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Improve checks for pkg-config and fall back to gpgme-config #168

Closed stanhu closed 1 year ago

stanhu commented 1 year ago

https://github.com/ueno/ruby-gpgme/pull/166 changed from pkg-config to gpgme-config, but if PKG_CONFIG_PATH is not set properly, the C extension library will quietly build without the right linker dependencies.

To fix this, we now check for the existence of gpgme.pc in PKG_CONFIG_PATH and attempt to fall back to gpgme-config if it does not exist.

Closes https://github.com/ueno/ruby-gpgme/issues/167

stanhu commented 1 year ago

Thanks @ueno! Would you mind tagging 2.0.23 with this?

ueno commented 1 year ago

I'm not sure if this single change qualifies a new release: we had no checks on the existence of gpgme-config for a decade and the issue can be easily worked around.

stanhu commented 1 year ago

@ueno The issue is that there is a regression in v2.0.22 due to #166. You can install a broken version of gpgme without knowing it by compiling all the gpgme dependencies from source, installing them in custom prefix, and then then running:

root@160b17998071:/# RUBY_GPGME_USE_SYSTEM_LIBRARIES=1 gem install gpgme
Building native extensions. This could take a while...
Successfully installed gpgme-2.0.22
Parsing documentation for gpgme-2.0.22
Done installing documentation for gpgme after 0 seconds
1 gem installed

The gem is broken:

root@160b17998071:/# irb
irb(main):001:0> require 'gpgme'
Traceback (most recent call last):
       10: from /usr/bin/irb:23:in `<main>'
        9: from /usr/bin/irb:23:in `load'
        8: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        7: from (irb):1
        6: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
        5: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
        4: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require'
        3: from /var/lib/gems/2.7.0/gems/gpgme-2.0.22/lib/gpgme.rb:3:in `<top (required)>'
        2: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
        1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
LoadError (/var/lib/gems/2.7.0/gems/gpgme-2.0.22/lib/gpgme_n.so: undefined symbol: gpgme_data_release - /var/lib/gems/2.7.0/gems/gpgme-2.0.22/lib/gpgme_n.so)