Introduction

Disclaimer: this section is just happy talking, if you want to get right to the beef, skip it and go right to the beef.

Yesterday was a sad day for me. It wasn't meant to be like that.

I began the day with the intention of setting up a development environment for this amazing RoR application I'll tell you about some other day. You know what it is like to set up a RoR environment: just a few gem installs here, a couple rakes there and voila! Two minutes after you started, you're all set to begin coding.

Well, no. One of the required gems was RMagick, a wrapper of the arch-famous ImageMagick graphics processing library. In order to be able to install the RMagick gem, you need first to install ImageMagick.

So far so good, but this library has a whole lot of dependencies, and if you're not a Unix and C Jedi (I'm not), it may be painful to get to a happy ending. I spent the day googling around looking for a good tutorial, and most of them recommended one of two alternatives:

I guess the reason why I failed with both alternatives is that at some point of the installation, I made a wrong a choice of version for any of the dependencies. By the end of the day, I still hadn't been able to start debugging the application.

Then I spoke to my colleague Adrian Romero (who unfortunately doesn´t have a blog to point you to), and he suggested me to try with Homebrew. This is how the story ends, I used Homebrew, and was able to get back on track quite quickly.

Brewing magic

1) Install Homebrew

2) Install Ghostscript:

sudo brew install ghostscript

Pre-3) Update! Before brewing imagemagick, you may need to install git:

sudo brew install git

I might have not realized this step was necessary because I had already installed git in my machine before. Thanks Nielson for pointing out this!

3) Install ImageMagick:

sudo brew install imagemagick

Ok, step 3 may not be that easy. One of the dependencies, Little CMS, may fail to install because they removed the file from the URL where Homebrew looks for it. This causes the ImageMagick installation process to abort.

I worked this issue around by replacing the URL in the Little CMS Homebrew formula with a location where at the moment of this post's publishing it can be found.

3a) Edit the formula:

sudo brew edit little-cms

3b) Look for this line:

url 'http://www.littlecms.com/lcms-1.19.tar.gz'

3c) Replace with:

url 'http://www.imagemagick.org/download/delegates/lcms-1.19.tar.gz' (or an URL where you could find "lcms-1.19.tar.gz")

3d) Try again to install ImageMagick (it should work now):

sudo brew install imagemagick

4) Welcome back home, just install the rmagick gem:

sudo gem install rmagick

5) Celebrate

Happy brewing!