Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

If you're on Ubuntu, installing this package is what fixed it for me:

sudo apt-get install libmagickwand-dev

It looks like ImageMagick 7 changed include file path.

On building rmagick, since it includes file as wand/MagickWand.h There are no workarounds. It looks like sticking with ImageMagick 6 for now.

On Mac OS X (I tested on Sierra), I used HomeBrew's versions tap like:

brew tap homebrew/versions
brew install imagemagick@6

Then, use the path shown on above installation:

PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

To install with ImageMagick 6.


I didn't want to mess with environment variables since I wanted bundler to be able to compile this gem on its own on a CI machine. Instead, I used Homebrew to install pkg-config:

brew install pkgconfig

and the next time I tried compiling the RMagick gem it found the header file without issue.

(This is pkg-config 0.28, ImageMagick 6.8.0-10, and RMagick 2.13.2, all on Mountain Lion.)


I had a similar issue with running

$ gem install rmagick

First of all, do you have imagemagick installed? If you're not sure, run

$ convert --version

If you do, you probably either installed it with fink or macports (maybe homebrew?). What is happening is that rvm can't find the imagemagick directory.

After reading https://superuser.com/questions/361435/i-have-compiled-imagemagick-on-my-centos-and-rmagick-wont-install I exported the imagemagick path by adding

$ export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"

to my ~/.bash_profile, sourcing the new profile, then running:

gem install rmagick

It worked for me after I did this.


fix this setting the include path of your current imagemagick installation:

Install ImageMagick with brew

brew install imagemagick

find library

$ mdfind MagickWand.h
/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/wand/MagickWand.h

Install rmagick gem

$ C_INCLUDE_PATH=/path/MagickWand.h gem install rmagick

example:

$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/ gem install rmagick

I marked this as a favorite because it seems to come back to bite me with every new system I need to install RMagick on (and time has passed and version numbers have rolled).

Mac OS X 10.8.4

rvm 1.22.3

ruby-2.0.0-p247

Xcode 4.6.3 developer tools installed

$ brew install imagemagick
==> /usr/local/Cellar/imagemagick/6.8.6-3

$ brew install pkgconfig
==> /usr/local/Cellar/pkg-config/0.28

$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/lib/pkgconfig/ gem install rmagick
Successfully installed rmagick-2.13.2

Many thanks to everyone who added helpful answers above!


Mac users using brew

If you can use v6 of ImageMagick instead of 7, you can try this

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

Note this will unlink your existing IM installation, so be careful if you have other projects on your machine using ImageMagick without problems.