Can't install RMagick 2.16.0. Can't find MagickWand.h Mac OS Sonoma

126 Views Asked by At

I'm using Mac OS Sonoma 14.2.1

ruby 2.6.5

imagemagick@6: stable 6.9.13-4

I'm trying to do gem install rmagick -v 2.16.0 catching it


Building native extensions. This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.
    current directory: /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/gems/rmagick-2.16.0/ext/RMagick
/Users/alenavolosina/.rbenv/versions/2.6.5/bin/ruby -I /Users/alenavolosina/.rbenv/versions/2.6.5/lib/ruby/2.6.0 -r ./siteconf20240111-64476-m23n6.rb extconf.rb
checking for clang... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** 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/alenavolosina/.rbenv/versions/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/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/extensions/-darwin-23/2.6.0/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/extensions/-darwin-23/2.6.0/rmagick-2.16.0/gem_make.out

The command find /usr/local /opt/homebrew -name "MagickWand.h" issues

/opt/homebrew/Cellar/imagemagick@6/6.9.13-4/include/ImageMagick-6/wand/MagickWand.h
/opt/homebrew/Cellar/imagemagick/7.1.1-26/include/ImageMagick-7/MagickWand/MagickWand.h

i tried it

brew install imagemagick@6 && brew link imagemagick@6 --force
export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
brew uninstall pkg-config && brew install pkg-config
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick -v '2.16.0'

etc.

I tried all stackoverflow and more, tried reinstalling all dependent libraries, I also reinstalled Ruby 2.6.5, using rbenv, I'm at a dead end, please help me, good people

2

There are 2 best solutions below

0
8bithero On

It looks like the MagickWand.h header file is missing. You could check the mkmf.log file for more details but here are some things to try that are the usual culprits with issues like these:

  1. Since you have already found MagickWand.h on your system, it's likely installed, but it might not be linked properly.
brew install imagemagick@6
brew link imagemagick@6 --force
  1. You've already set the PKG_CONFIG_PATH Environment Variable, but ensure that it's pointing to the correct version of ImageMagick
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
  1. Sometimes, explicitly telling the gem where to find MagickWand.h can help
gem install rmagick -v '2.16.0' -- --with-magick-wand-include="/usr/local/opt/imagemagick@6/include/ImageMagick-6/wand"

If none of these work you could then try uninstalling and reinstalling imagemagick & rmagick. Also make sure you don't have multiple versions installed. This can sometimes cause conflicts. The last thing I can think of would be to try uninstall and reinstall ruby, and also ensure your macOS is up to date as it can sometimes cause issues.

0
Art Chaz On

While all points from 8bithero are correct, the bug is specific to ImageMagick 6.9.13-4 version and it is actually in MagickWand-config file(/usr/local/Cellar/imagemagick@6/bin/MagickWand-config): line 9 is missing closing quotes

export PKG_CONFIG_LIBDIR="${exec_prefix}/lib/pkgconfig

so all you need is to change the line to:

export PKG_CONFIG_LIBDIR="${exec_prefix}/lib/pkgconfig"

Took me a few days to find it