Skip to content

Ensure GPGME can be installed in latest MacOS

Gabriel Mazetto requested to merge brodock/fix-gpgme into main

What does this merge request do and why?

Adds libassuan@2 to Brewfile in order to install the correct dependency file to compile gpgme gem.

Adds the following bundle setting (on MacOS only):

bundle config build.gpgme --with-libassuan-prefix="/opt/homebrew/opt/libassuan@2/"

To ensure Bundler pass the correct libassuan path to the compilation process.

How to set up and validate locally

How to ensure you see the same problem:

  1. Run brew update

  2. Run brew upgrade

  3. Ensure libassuan is installed (with a 3.x version):

    $ brew list --versions libassuan
    libassuan 3.0.1
  4. Try to gem install gpgme -v 2.0.23

This is an example output of the error:

$ bundle
Fetching gem metadata from https://rubygems.org/.......
Installing gpgme 2.0.23 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/brodock/.rvm/gems/ruby-3.2.4/gems/gpgme-2.0.23/ext/gpgme
/Users/brodock/.rvm/rubies/ruby-3.2.4/bin/ruby extconf.rb
************************************************************************
IMPORTANT!  gpgme gem uses locally built versions of required C libraries,
namely libgpg-error, libassuan, and gpgme.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall gpgme gem as
follows:

    gem install gpgme -- --use-system-libraries

************************************************************************
Extracting libgpg-error-1.47.tar.bz2 into tmp/arm64-apple-darwin23.6.0/ports/libgpg-error/1.47... OK
Running 'configure' for libgpg-error 1.47... OK
Running 'compile' for libgpg-error 1.47... OK
Running 'install' for libgpg-error 1.47... OK
Activating libgpg-error 1.47 (from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/gpgme-2.0.23/ports/arm64-apple-darwin23.6.0/libgpg-error/1.47)...
Extracting libassuan-2.5.6.tar.bz2 into tmp/arm64-apple-darwin23.6.0/ports/libassuan/2.5.6... OK
Running 'configure' for libassuan 2.5.6... OK
Running 'compile' for libassuan 2.5.6... OK
Running 'install' for libassuan 2.5.6... OK
Activating libassuan 2.5.6 (from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/gpgme-2.0.23/ports/arm64-apple-darwin23.6.0/libassuan/2.5.6)...
Extracting gpgme-1.21.0.tar.bz2 into tmp/arm64-apple-darwin23.6.0/ports/gpgme/1.21.0... OK
Running 'configure' for gpgme 1.21.0... ERROR. Please review logs to see what happened:
----- contents of '/Users/brodock/.rvm/gems/ruby-3.2.4/gems/gpgme-2.0.23/ext/gpgme/tmp/arm64-apple-darwin23.6.0/ports/gpgme/1.21.0/configure.log' -----
...
configure: exit 1
----- end of file -----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/brodock/.rvm/rubies/ruby-3.2.4/bin/$(RUBY_BASE_NAME)
	--clean
	--use-system-libraries
/Users/brodock/.rvm/gems/ruby-3.2.4/gems/mini_portile2-2.8.5/lib/mini_portile2/mini_portile.rb:612:in `block in execute': Failed to complete configure task (RuntimeError)
	from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/mini_portile2-2.8.5/lib/mini_portile2/mini_portile.rb:578:in `chdir'
	from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/mini_portile2-2.8.5/lib/mini_portile2/mini_portile.rb:578:in `execute'
	from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/mini_portile2-2.8.5/lib/mini_portile2/mini_portile.rb:188:in `configure'
	from /Users/brodock/.rvm/gems/ruby-3.2.4/gems/mini_portile2-2.8.5/lib/mini_portile2/mini_portile.rb:234:in `cook'
	from extconf.rb:133:in `block in <main>'
	from <internal:kernel>:90:in `tap'
	from extconf.rb:109:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/brodock/.rvm/gems/ruby-3.2.4/gems/gpgme-2.0.23 for inspection.
Results logged to /Users/brodock/.rvm/gems/ruby-3.2.4/extensions/arm64-darwin-23/3.2.0/gpgme-2.0.23/gem_make.out

  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/builder.rb:119:in `run'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/builder.rb:187:in `build_extension'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `each'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `build_extensions'
  /Users/brodock/.rvm/rubies/ruby-3.2.4/lib/ruby/3.2.0/rubygems/installer.rb:846:in `build_extensions'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/source/rubygems.rb:206:in `install'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/installer/parallel_installer.rb:132:in `do_install'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/installer/parallel_installer.rb:123:in `block in worker_pool'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/worker.rb:62:in `apply_func'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/worker.rb:54:in `loop'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/worker.rb:54:in `process_queue'
  /Users/brodock/.rvm/gems/ruby-3.2.4/gems/bundler-2.5.11/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing gpgme (2.0.23), and Bundler cannot continue.

Running an update with the changes should trigger brew bundle and bootstrap logic.

Alternatively, run just the following:

  1. make platform-update (this is run as part of gdk update, it triggers the brew bundle)
  2. make gitlab-bundle-prepare (this configures bundler with the gpgme specific compilation flags)

Then cd into gitlab folder:

  1. Run bundle config build.gpgme and check it has similar content:

    Set for your local app (.../gdk-dev/gitlab/.bundle/config): "--with-libassuan-prefix=/opt/homebrew/opt/libassuan@2/"
  2. Run bundle install and wait for it to build gpgme correctly

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise an issue to follow-up.
  • Documentation added/updated, if needed.
  • Announcement added, if change is notable.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.
Edited by Gabriel Mazetto

Merge request reports

Loading