Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RMagick installation: Can't find MagickWand.h

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 ✓
like image 382
0x4a6f4672 Avatar asked Sep 14 '16 15:09

0x4a6f4672


4 Answers

To solve the issue in Mac OSX Sierra, High Sierra, El Capitan, Mojave, Catalina, Big Sur, and Monterey (M1 chip), 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.

like image 152
K M Rakibul Islam Avatar answered Nov 07 '22 19:11

K M Rakibul Islam


I had this same issue with ImageMagick 7.0.4-4. The proper fix is to install imagemagick@6. I found https://github.com/Homebrew/homebrew-core/pull/8756 useful if you accidentally deleted your imagemagick@6 or never had it installed in the first place.

like image 57
Raymond Cox Avatar answered Nov 07 '22 18:11

Raymond Cox


First of all unlink your installed imagemagick which was not properly installed in latest mac high sierra by using.

brew unlink imagemagick

then install latest imagemagic6 using below command

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

Then install gem rmagick using below command

gem install rmagick 

It will work perfectly fine.

like image 23
Ali Hassan Mirza Avatar answered Nov 07 '22 18:11

Ali Hassan Mirza


macOs Sierra:

brew uninstall imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
like image 33
Evgeniy28 Avatar answered Nov 07 '22 17:11

Evgeniy28