rmagick: ERROR: Can't install RMagick 4.0.0. Can't find ImageMagick with pkg-config

Hello, I upgraded imagemagick version to 6.9.11 and when i try install rmagick gem, i get following error:

# mkmf.log

find_executable: checking for brew... -------------------- yes
--------------------
find_executable: checking for gcc... -------------------- yes
--------------------
find_executable: checking for pkg-config... -------------------- yes
--------------------
ERROR: Can't install RMagick 4.0.0. Can't find ImageMagick with pkg-config
current directory: /Users/michalmacku/.rvm/gems/ruby-2.6.5/gems/rmagick-4.1.0.rc2/ext/RMagick
/Users/michalmacku/.rvm/rubies/ruby-2.6.5/bin/ruby -I /Users/michalmacku/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200309-20030-8vw80k.rb extconf.rb
checking for brew... yes
checking for gcc... yes
checking for pkg-config... yes


ERROR: Can't install RMagick 4.1.0.rc2. Can't find ImageMagick with pkg-config


*** 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
	--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/michalmacku/.rvm/rubies/ruby-2.6.5/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/michalmacku/.rvm/gems/ruby-2.6.5/extensions/x86_64-darwin-19/2.6.0/rmagick-4.1.0.rc2/mkmf.log

extconf failed, exit code 1

I had installed pkg-config on my system. I tried to reinstall imagemagick and pkg-config but problem persists. Similar problem looks like https://github.com/rmagick/rmagick/issues/956 but that solution not working for me. Imagemagick version 6.9.10 working without problem, but after upgrade it via Homebrew i cannot go back to previous version.

My operating system is MacOS.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (5 by maintainers)

Most upvoted comments

I was blocked by this as well with the same pkg-config --list-all segfault behavior. Changing the env variables PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR didn’t seem to change the paths used, which I believe can be checked by running pkg-config --variable pc_path pkg-config. I was able to debug that by running pkg-config --debug --list-all which segfaulted while Parsing package file '/usr/local/lib/pkgconfig/proj.pc'. The package PROJ was updated 11 days ago and that running pkg-config --exists --print-errors "proj" results in Variable 'datarootdir' not defined in '/usr/local/lib/pkgconfig/proj.pc'. Removing /usr/local/lib/pkgconfig/proj.pc (renaming it to proj.pc.backup) and re-running the RMagick install succeeded! Will be opening an issue for PROJ, and attempting to downgrade PROJ from 7.0.0 for now. Hope this helps! Doesn’t seem to be an issue with RMagick, although maybe the determine_imagemagick_package method could be modified to not use --list-all as a workaround.

is there a longer term fix planned than the current workaround to

brew install pkg-config imagemagick
brew  uninstall highway
bundle install
brew install highway

?

Unfortunately I used to still get the same error and also the rmagick installation issue:

pkg-config --list-all
[1]    664 segmentation fault  pkg-config --list-all

pkg-config has version 0.29.2, I tried both removing the proj.pc file and changing it to the details from this comment.

pkg-config --exists --print-errors "proj" even returns nothing, so I don’t think there’s an error on that side.

I managed to fix the issue by uninstall highway (brew uninstall highway), because it has a conflict over a variable. Running pkg-config --debug --list-all will show that.

is there a longer term fix planned than the current workaround to

brew install pkg-config imagemagick
brew  uninstall highway
bundle install
brew install highway

?

This worked for me!

Looks like pkg-config on your sysytem have some damage… You need to solve the segmentation fault at first. You may solve the problem by reinstalling pkg-config. (ex brew reinstall --force pkgconfig)

For me, the issue was not with proj.pc but with libhwy-test. Running an Apple M1 Pro Chip. Ran the same solution as above and could install rmagick fine. I don’t like the idea of just removing a file for what seems like a dependency but I will say that it worked.

Reading '/opt/homebrew/lib/pkgconfig/libhwy-test.pc' from file '/opt/homebrew/lib/pkgconfig/libhwy-test.pc'
Parsing package file '/opt/homebrew/lib/pkgconfig/libhwy-test.pc'
  line>prefix=/opt/homebrew/Cellar/highway/1.0.1
 Variable declaration, 'prefix' has value '/opt/homebrew/Cellar/highway/1.0.1'
  line>libdir=${exec_prefix}/lib
[1]    81028 segmentation fault  pkg-config --debug --list-all
❯ pkg-config --exists --print-errors "libhwy-test"
Variable 'exec_prefix' not defined in '/opt/homebrew/lib/pkgconfig/libhwy-test.pc'

Can you paste the following command log?

$ export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
$ pkg-config --list-all