Paulo Poiati | Blog

Installing RMagick in Mac OS X Mountain Lion / Maverick with Homebrew

Installing RMagick with homebrew should be trivial, but it’s not. For some reason the last version of RMagick (2.13.1) does not compile with the last version of ImageMagick (6.8.2-0).

If you install the last version of ImageMagick with homebrew it will work without problems but the RMagick extension will fail during the build with the following error:

checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.13.1. Can't find the ImageMagick library or one
of the dependent libraries. Check the mkmf.log file for more detailed
information.

I’m not sure but I think there are some compatibility problems with the new versions of ImageMagick and RMagick. One version I know works well is 6.6.7-0 let’s install it using homebrew.

If you already have ImageMagick installed uninstall it before continue.

$ brew uninstall imagemagick

Now let’s edit the brew formula.

$ brew edit imagemagick

You should set the url to ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/ImageMagick-6.6.7-0.tar.gz and comment the sha256 line.

class Imagemagick < Formula
  homepage 'http://www.imagemagick.org'

  # upstream's stable tarballs tend to disappear, so we provide our own mirror
  # Tarball from: http://www.imagemagick.org/download/ImageMagick.tar.gz
  # SHA-256 from: http://www.imagemagick.org/download/digest.rdf
 
  # Remove this url
  # url 'http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.8.0-10.tar.gz'
 
  # Add this new url
  url 'ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/ImageMagick-6.6.7-0.tar.gz'

  # Comment this line
  # sha256 'b3dfcb44300f73e73ffa8deef8bba4cf43f03d7150bf1fd0febedceac1a45c7e'

  head 'https://www.imagemagick.org/subversion/ImageMagick/trunk',
    :using => UnsafeSubversionDownloadStrategy

  .
  .
  .
end

After saving the file you can install ImageMagick. You should also disable openmp and build it from source.

$ brew install imagemagick --disable-openmp --build-from-source

Now the RMagick installation should work like a charm!

$ gem install rmagick
comments powered by Disqus