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:
- Use MacPorts: tried, no success.
- Use a script that some guy put together once. Basically it consisted of downloading, compiling and installing all the dependencies, and then ImageMagick: tried, no success.
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
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!
Hi there!
I’m trying your approach to installing imagemagick but am having problems brewing ghostscript.
I get the following message:
[code]
==> Downloading http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip
### 4.9%
curl: (18) transfer closed with 1346514 bytes remaining to read
Failure while executing: curl -f#LA 'Homebrew 0.6 (Ruby 1.8.7-173; Mac OS X 10.6.3)' http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip -o /Library/Caches/Homebrew/jasper-1.900.1.zip
[/code]
I have tried many times but the process never finishes because of this server problem .
Do you have any advice on this matter? thanks a lot for any help you can give me
Ok: The server were Jasper is located have many issues when downloading files, I manage to do it upon many failures.
The installation process is easy but it does take a long time
Pingback: MacPorts is a monster | Refactoring Thoughts
THANK YOU!
Hi,
imagemagick didn’t work – complained about “‘–trust-server-cert’” so just do:
sudo brew edit imagemagick
and remove ‘–trust-server-cert’ and ‘–non-interactive’. You are prompted, but it works.
Dan
Hi! I just installed icmgeaagimk using homebrew. However i want to run a demo code and is not working. It gives me the follwoing errorssmile.c:8:24: error: magick/api.h: No such file or directorysmile.c: In function ‘main’:smile.c:116: error: ‘Image’ undeclared (first use in this function)smile.c:116: error: (Each undeclared identifier is reported only oncesmile.c:116: error: for each function it appears in.)smile.c:117: error: ‘image’ undeclared (first use in this function)smile.c:119: error: ‘ImageInfo’ undeclared (first use in this function)smile.c:120: error: ‘image_info’ undeclared (first use in this function)smile.c:129: error: nested functions are disabled, use -fnested-functions to re-enablesmile.c:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ tokensmile.c:129: error: ‘q’ undeclared (first use in this function)smile.c:138: error: expected expression before ‘)’ tokensmile.c:149: error: ‘PixelPacket’ undeclared (first use in this function)smile.c:149: error: expected expression before ‘)’ tokensmile.c:153: error: ‘MaxRGB’ undeclared (first use in this function)how do i have to exactly compile the program. Please help me, I have spend the past 7 hours looking for an answer! Thanks
Hi Dan! It did work when I wrote the post, something may have broken since. Thank you very much for the update!
Hi Dan, the –trust-server-cert is due to an old version of subversion. brew install subversion first, then you don’t have to hack the imagemagick recipe.
, you should never, ever use sudo with brew. If you have to use sudo then you have a peisnsmrois issue and need to fix that instead of using the sudo hammer with the install.If you use sudo then you’re basically ignoring the problem and it will come back to bite you later, usually when you find yourself in an emergency and need to publish but can’t for some reason.
Thanks for posting this! Saved me a lot of googling time having all the steps in one place. Worked like a charm.
I just installed imagemagick without having to edit the formula. It seems they put the lcms-1.19.tar.gz file back in its place so Homebrew could find it.
But first, I had to install git before install imagemagick:
sudo brew install git
Pingback: Instalando Imagemagick no Mac OS X com o Homebrew | Meu Arquivo
Thank you for pointing this out Nielson! Already updated the post to reflect your remark.
So I just did this, and Little CMS works once again. There is no need to edit the url at this point.
Thanks for the helpful post!
Had to grab from Sourceforge:
http://downloads.sourceforge.net/project/lcms/lcms/2.1/lcms2-2.1.tar.gz
Worked perfectly fine. As Nielson stated, i didn’t had to edit the formula either.
Many thanks
In case anyone has an issue installing ghostscript on 10.7 lion gm:
https://github.com/mxcl/homebrew/issues/6381
Cheers
Luke
Homebrew doesn’t require “sudo”. Sudo is discouraged with brew and should not be used.
Hi! I just installed imagemagick using homebrew. However i want to run a demo code and is not working. It gives me the follwoing errors
smile.c:8:24: error: magick/api.h: No such file or directory
smile.c: In function ‘main’:
smile.c:116: error: ‘Image’ undeclared (first use in this function)
smile.c:116: error: (Each undeclared identifier is reported only once
smile.c:116: error: for each function it appears in.)
smile.c:117: error: ‘image’ undeclared (first use in this function)
smile.c:119: error: ‘ImageInfo’ undeclared (first use in this function)
smile.c:120: error: ‘image_info’ undeclared (first use in this function)
smile.c:129: error: nested functions are disabled, use -fnested-functions to re-enable
smile.c:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
smile.c:129: error: ‘q’ undeclared (first use in this function)
smile.c:138: error: expected expression before ‘)’ token
smile.c:149: error: ‘PixelPacket’ undeclared (first use in this function)
smile.c:149: error: expected expression before ‘)’ token
smile.c:153: error: ‘MaxRGB’ undeclared (first use in this function)
how do i have to exactly compile the program. Please help me, I have spend the past 7 hours looking for an answer! Thanks
Thank you!
Thanks for the great info.
I just wanted to reiterate what Sharad said, you should never, ever use sudo with brew. If you have to use sudo then you have a permissions issue and need to fix that instead of using the sudo hammer with the install.
If you use sudo then you’re basically ignoring the problem and it will come back to bite you later, usually when you find yourself in an emergency and need to publish but can’t for some reason.
Good point Mike, thanks for the advice. I guess that’s kind of a general rule: when you take a lazy approach, usually it’ll come back to bite you later. And that’s because we human beings suck at mid-term risk evaluation (we may be averse to cross an avenue when the lights are red but we don’t mind eating those extra French fries which will cause our cholesterol to rise even more)
This was good, I tried around a long time, pointing to this helped.
Pingback: My Homepage
Fore ImageMagick this no longer works http://www.imagemagick.org/download/delegates/lcms-1.19.tar.gz
I used this instead: http://sourceforge.net/projects/lcms/files/lcms/1.19/lcms-1.19.tar.gz
I just installed igcaemmgiak without having to edit the formula. It seems they put the lcms-1.19.tar.gz file back in its place so Homebrew could find it.But first, I had to install git before install igcaemmgiak:sudo brew install git