How to install RMagick RubyGem on Mac OS X 10.6 Snow Leopard?

I am getting this error while trying to install RMagick:

$ sudo gem install rmagick

Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:~/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/pear/bin

*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

How can I install the RMagick RubyGem on Snow Leopard?


Solution 1:

You might also consider taking Homebrew for a spin. It's been growing over the last year and is widely used as an alternative to MacPorts.

Homebrew is a reaction to the complexity of MacPorts. It’s extremely simple. Homebrew appears to be targeted more at individual packages. If you want to pull in the entire world of open source software and want every package, then you’re better off with MacPorts or Fink. But if you’re looking for the occasional tool or utility, Homebrew is for you.

Solution 2:

I found a way to do it without having to use MacPorts. Thanks to a shell script to Install ImageMagick on Snow Leopard, I was easily able to run the script and have ImageMagick and all of its dependencies installed automatically.

First you need to download the script. If you have git installed...

cd ~/src
git clone git://github.com/masterkain/ImageMagick-sl.git
cd ImageMagick-sl
sh install_im.sh

At one point, it runs a command using sudo, so it will ask for your password. After the script has finished, ImageMagick will be installed. Now, to install the RMagick gem...

sudo gem install rmagick

That's it!

Solution 3:

OS X does not come with ImageMagick installed by default. The ImageMagick home page provides a binary installation, although they recommend using MacPorts instead. I would recommend using MacPorts as well, since it is a great package management system that keeps you up to date with your Unix-like software versus Apple's provided versions.

Having said that, Rubyforge has some instructions on installing RMagick on OS X using MacPorts. It's slightly dated, and you might need to choose different variants for the ImageMagick installation, but it should work to get what you want.