RMagick installation: Can't find MagickWand.h

0x4a6f4672 picture 0x4a6f4672 · Sep 14, 2016 · Viewed 43.4k times · Source

Updating RMagick and Imagemagick is a painful expierence. I have updated the Imagemagick version on my mac (MacOS El Capitan Version 10.11.5) with homebrew for one project in Ruby 2.3 to 6.9.5-9

$ convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-09

Now an older project in Ruby 1.8.7 refuses to work with the error message "this installation of RMagick was configured with ImageMagick 6.8.9 but ImageMagick 6.9.5-9 is in use". Thus I uninstalled "rmagick", but it can not be installed again

$ gem install rmagick -v 2.16.0
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
ERROR: Failed to build gem native extension.

checking for /usr/local/opt/gcc46/bin/gcc-4.6... 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... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h. 

And if it can not be installed, the whole application can not be started. I tried all the answers from here, and none of them works on MacOS :-( I reinstalled imagemagick and pkg-config with homebrew, and tried various version of RMagick without success. 2.16.0 is the latest version of RMagick currently.

MagicWand seems to be used in ImageMagick version > 6.9, and it can be found on the machine:

find /usr/local -name MagickWand.h
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6/wand/MagickWand.h

find /usr/local -name MagickWand.pc
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/lib/pkgconfig/MagickCore.pc

It does not work even if I specifiy the these paths during the gem install (same error as above) :-(

C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick

UPDATE:

The error only occurs for Ruby 1.8.7, it is possible to install RMagick for Ruby 2.0 and Ruby 2.3. Ruby 1.8.7 and ImageMagick 6.9.5 do not seem to be compatible.

  • Ruby 1.8.7 x
  • Ruby 2.0.0 ✓
  • Ruby 2.3.1 ✓

Answer

K M Rakibul Islam picture K M Rakibul Islam · Mar 27, 2017

To solve the issue in Mac OSX Sierra, High Sierra, El Capitan, Mojave, and Catalina, you can do the following:

brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force

imagemagick@6 is keg-only, so you'll need to force linking.