MacPorts x HomeBrew, a quick story.

UPDATE: It is 100% worth your time, dear reader, to check out the comments on this post. Lots of very smart people took time to really turn this into a valuable discussion! Scroll to the bottom and see the ongoing interesting discussion :)

*********** ORIGINAL POST BEGINS ***********

So I spent a few hours last night trying to get giflib to work on my new OSX instance. Very exciting cutting edge stuff, I asure you. It turns out it is a dependency on some module that is a dependency of a module that is a dependency of a module. You know how it is. Well, the way I had installed Unix dependencies historically was with MacPorts. Well, originally it had been with Fink, but I had learned my lesson about using Fink. So I set up MacPorts and went to town happily telling my system: sudo port install giflib.

I should have known I was in trouble when suddenly I found myself waiting for xorg and expat. No matter, I thought, these people know what they are doing, I’ll soldier on.  Eventually giflib was “installed” into the completely standard /opt/local/your_face/your_mom hierarchy that makes it work oh-so-well with most UNIX tools. Suffice it to say, things didn’t work out so hot:

bash-3.2$ perl Makefile.PL –incpath=/opt/local/include –libpath=/opt/local/lib
GIF: building independently
GIF: main: includes found – libraries found
GIF: Test code failed: Can’t link/include ‘gif’
GIF: Checking if the compiler can find them on its own
Note (probably harmless): No library found for -lgif
GIF: Test code failed: Can’t link/include ‘gif’
OS unsupported: GIF libraries or headers not found

Now, before you waste your breath telling me how I should have fixed this, I don’t care. If I install a library using a tool that is for installing UNIX dependencies, I shouldn’t have to fix it. I already was trying to fix it by setting the libpath and includepath in the command line. So, I twittered in disgust. Here is the conversation which followed:

Image

Now, mind you, @kabobbob knows his shit. But it was late, and I was ornery. I don’t want to have to sysadmin my toaster. I don’t think it’s too much to ask for a unix library to just work, when you install it. So, I went to sleep and had horrible nightmares about DLL conflicts. When I woke up, however, I felt like this problem needed re-addressing, and I remembered his sage advice:

Image

So, against my better judgement. I went out and decided to re-try homebrew. (I had done so at some point in the past, and it had crushed some stuff in /usr/local (mysql I think?) and made me grumpy. But dagnabit, I was at least going to fail currently.)

So first I delete macports. For posterity’s sake, I want the world to see what gets installed when you install giflib with macports:

bash-3.2$ sudo port -fp uninstall –follow-dependents installed
Password:
—> Deactivating giflib @4.2.0_2+x11
—> Cleaning giflib
—> Uninstalling giflib @4.2.0_2+x11
—> Cleaning giflib
—> Deactivating xorg-libX11 @1.5.0_0
—> Cleaning xorg-libX11
—> Uninstalling xorg-libX11 @1.5.0_0
—> Cleaning xorg-libX11
—> Deactivating xorg-libxcb @1.8.1_2+python27
—> Cleaning xorg-libxcb
—> Uninstalling xorg-libxcb @1.8.1_2+python27
—> Cleaning xorg-libxcb
—> Deactivating xorg-xcb-proto @1.7.1_0+python27
—> Cleaning xorg-xcb-proto
—> Uninstalling xorg-xcb-proto @1.7.1_0+python27
—> Cleaning xorg-xcb-proto
—> Deactivating python27 @2.7.3_0
—> Cleaning python27
—> Uninstalling python27 @2.7.3_0
—> Cleaning python27
—> Deactivating bzip2 @1.0.6_0
—> Cleaning bzip2
—> Uninstalling bzip2 @1.0.6_0
—> Cleaning bzip2
—> Deactivating db46 @4.6.21_6
—> Cleaning db46
—> Uninstalling db46 @4.6.21_6
—> Cleaning db46
—> Deactivating gettext @0.18.1.1_2
—> Cleaning gettext
—> Uninstalling gettext @0.18.1.1_2
—> Cleaning gettext
—> Deactivating expat @2.1.0_0
—> Cleaning expat
—> Uninstalling expat @2.1.0_0
—> Cleaning expat
—> Deactivating sqlite3 @3.7.13_0
—> Cleaning sqlite3
—> Uninstalling sqlite3 @3.7.13_0
—> Cleaning sqlite3
—> Deactivating libedit @20120601-3.0_0
—> Cleaning libedit
—> Uninstalling libedit @20120601-3.0_0
—> Cleaning libedit
—> Deactivating libxml2 @2.7.8_0
—> Cleaning libxml2
—> Uninstalling libxml2 @2.7.8_0
—> Cleaning libxml2
—> Deactivating libiconv @1.14_0
—> Cleaning libiconv
—> Uninstalling libiconv @1.14_0
—> Cleaning libiconv
—> Deactivating libpng @1.4.11_0
—> Cleaning libpng
—> Uninstalling libpng @1.4.11_0
—> Cleaning libpng
—> Deactivating ncurses @5.9_1
—> Cleaning ncurses
—> Uninstalling ncurses @5.9_1
—> Cleaning ncurses
—> Deactivating openssl @1.0.1c_0
—> Cleaning openssl
—> Uninstalling openssl @1.0.1c_0
—> Cleaning openssl
—> Deactivating python_select @0.3_1
—> Cleaning python_select
—> Uninstalling python_select @0.3_1
—> Cleaning python_select
—> Deactivating xorg-kbproto @1.0.6_0
—> Cleaning xorg-kbproto
—> Uninstalling xorg-kbproto @1.0.6_0
—> Cleaning xorg-kbproto
—> Deactivating xorg-libsm @1.2.1_0
—> Cleaning xorg-libsm
—> Uninstalling xorg-libsm @1.2.1_0
—> Cleaning xorg-libsm
—> Deactivating xorg-libice @1.0.8_0
—> Cleaning xorg-libice
—> Uninstalling xorg-libice @1.0.8_0
—> Cleaning xorg-libice
—> Deactivating xorg-libpthread-stubs @0.3_0
—> Cleaning xorg-libpthread-stubs
—> Uninstalling xorg-libpthread-stubs @0.3_0
—> Cleaning xorg-libpthread-stubs
—> Deactivating xorg-libXau @1.0.7_0
—> Cleaning xorg-libXau
—> Uninstalling xorg-libXau @1.0.7_0
—> Cleaning xorg-libXau
—> Deactivating xorg-libXdmcp @1.1.1_0
—> Cleaning xorg-libXdmcp
—> Uninstalling xorg-libXdmcp @1.1.1_0
—> Cleaning xorg-libXdmcp
—> Deactivating xorg-xproto @7.0.23_0
—> Cleaning xorg-xproto
—> Uninstalling xorg-xproto @7.0.23_0
—> Cleaning xorg-xproto
—> Deactivating zlib @1.2.7_0
—> Cleaning zlib
—> Uninstalling zlib @1.2.7_0
—> Cleaning zlib
bash-3.2$ sudo rm -rf \
> /opt/local \
> /Applications/DarwinPorts \
> /Applications/MacPorts \
> /Library/LaunchDaemons/org.macports.* \
> /Library/Receipts/DarwinPorts*.pkg \
> /Library/Receipts/MacPorts*.pkg \
> /Library/StartupItems/DarwinPortsStartup \
> /Library/Tcl/darwinports1.0 \
> /Library/Tcl/macports1.0 \
> ~/.macports

Seriously, ncurses and libpng are installed if you want libgif. That’s good shit right there.

So, I go to the Homebrew home page and think, “Oh good, a ruby tool. Ruby people, sheesh. (the hero of the story @kabobbob is one of *those* people, Ruby folks.)”  And honestly, that was the last thought I was able to get in my head before the entire damned system was up and running. Seriously, from “i don’t have giflib or homebrew or any of that shit” to “fully functional system including having the original module and prerequisites installed was like, 60 seconds.

bash-3.2$ /usr/bin/ruby -e “$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)”
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/…
/usr/local/Library/Homebrew/…
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin

Press enter to continue
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin
==> Downloading and Installing Homebrew…
==> Installation successful!
You should run `brew doctor’ *before* you install anything.
Now type: brew help
bash-3.2$ brew doctor
Your system is raring to brew.
bash-3.2$ brew install giflib
==> Downloading http://downloads.sourceforge.net/project/giflib/giflib-4.x/giflib-4.1.6/giflib-4.1.6.tar.bz2
######################################################################## 100.0%
==> ./configure –prefix=/usr/local/Cellar/giflib/4.1.6 –disable-debug
==> make install
/usr/local/Cellar/giflib/4.1.6: 37 files, 680K, built in 19 seconds
bash-3.2$ cpanm –prompt Imager::File::GIF
–> Working on Imager::File::GIF
Fetching http://www.cpan.org/authors/id/T/TO/TONYC/Imager-File-GIF-0.83.tar.gz … OK
Configuring Imager-File-GIF-0.83 … OK
Building and testing Imager-File-GIF-0.83 … OK
Successfully installed Imager-File-GIF-0.83
1 distribution installed

So yeah, that about covers it. @kabobbob’s advice was golden, MacPorts has become a tangled web of crazy, homebrew seems totally workable and didn’t blow away my /usr/local in any way shape or form, and I now can get back to looking at pictures of adorable puppies. Can’t go wrong with that.

 

This entry was posted in tech and tagged , , , , , , , . Bookmark the permalink.

15 Responses to MacPorts x HomeBrew, a quick story.

  1. After a few years of having MacPorts and Homebrew installed, I got fed up with MacPorts on my machine and uninstalled & rm -rf. What I didn’t realize at the time was how much stuff I had installed under MacPorts, notably my Postgres instance. :( Oh well, at least Homebrew was quick about installing it!

    P.S. I’m trying out Clojure these days…so there!

    • earino says:

      What do you think of Clojure? It seems like it would be awesome for the 3 people on earth who really need that kind of concurrency. What are your thoughts?

      • Learning Clojure has been a challenge and an experience. The biggest challenge has been learning functional programming along side as I never took the opportunity to learn lisp. It has been enjoyable. We’re trying to apply to a project that we’re picking our way through.

  2. flatline3 says:

    I think that perhaps you should have spoken to a MacPorts expert instead of a ruby expert.

    user@epsilon> sudo port variants giflib
    giflib has the variants:
    doc: Install HTML documentation
    no_x11: Legacy compatibility variant
    * conflicts with x11
    universal: Build for multiple architectures
    [+]x11: Enable X11 support

    user@epsilon> sudo port install giflib -x11
    —> Fetching archive for giflib
    —> Attempting to fetch giflib-4.2.0_2.darwin_11.x86_64.tbz2 from http://packages.macports.org/giflib
    —> Fetching distfiles for giflib
    —> Attempting to fetch giflib-4.2.0.tar.bz2 from http://ykf.ca.distfiles.macports.org/MacPorts/mpdistfiles/giflib/4.2.0_1
    —> Verifying checksum(s) for giflib
    —> Extracting giflib
    —> Applying patches to giflib
    —> Configuring giflib
    —> Building giflib
    —> Staging giflib into destroot
    —> Installing giflib @4.2.0_2
    —> Activating giflib @4.2.0_2
    —> Cleaning giflib
    —> Updating database of binaries: 100.0%
    —> Scanning binaries for linking errors: 100.0%
    —> No broken files found.

    • earino says:

      So what do I have to do to my environment variables so that I can just do -lgif with gcc and it work? That was really what ended up driving me into homebrew’s eagerly awaiting arms?

      • flatline3 says:

        It looks like homebrew ships an out-of-date version of giflib, and p5-Imager’s version detection is broken with the newer version of giflib available through MacPorts.

        This patch appears to fix p5-Imager: http://www.freebsd.org/cgi/cvsweb.cgi/ports/graphics/p5-Imager/files/patch-GIF_LIB_VERSION?rev=1.1;content-type=text%2Fplain

        eg:

        user@epsilon:~/Downloads/Imager-0.91> curl ‘http://www.freebsd.org/cgi/cvsweb.cgi/ports/graphics/p5-Imager/files/patch-GIF_LIB_VERSION?rev=1.1;content-type=text%2Fplain’ | patch -p0
        % Total % Received % Xferd Average Speed Time Time Time Current
        Dload Upload Total Spent Left Speed
        100 637 0 637 0 0 613 0 –:–:– 0:00:01 –:–:– 1361
        patching file GIF/Makefile.PL
        patching file GIF/imgif.c

        user@epsilon:~/Downloads/Imager-0.91> perl Makefile.PL –incpath=/opt/local/include –libpath=/opt/local/lib

        done.
        TT-fonts: includes not found – libraries not found
        Writing Makefile for Imager::CountColor
        Writing Makefile for Imager::Filter::DynTest
        FreeType 2: configured via freetype-config
        FreeType 2: Passed code check
        Writing Makefile for Imager::Font::FT2
        Writing Makefile for Imager::Filter::Flines
        GIF: main: includes found – libraries found
        GIF: Major 4, Minor 2
        GIF: Passed code check
        Writing Makefile for Imager::File::GIF
        Writing Makefile for Imager::File::ICO
        JPEG: main: includes found – libraries found
        JPEG: Passed code check
        Writing Makefile for Imager::File::JPEG
        Writing Makefile for Imager::Filter::Mandelbrot
        PNG: Found via pkg-config libpng14
        PNG: library version 10411, header version 10411
        PNG: Passed code check
        Writing Makefile for Imager::File::PNG
        Writing Makefile for Imager::File::SGI
        T1Lib: main: includes not found – libraries not found
        T1Lib: Checking if the compiler can find them on its own
        Note (probably harmless): No library found for -lt1
        T1Lib: Test code failed: Can’t link/include ‘t1lib.h’, ‘t1′
        TIFF: main: includes found – libraries found
        TIFF: library version 3.9.5, header version 20110409
        TIFF: Passed code check
        Writing Makefile for Imager::File::TIFF
        Win32: main: includes not found – libraries not found
        Win32: Checking if the compiler can find them on its own
        Note (probably harmless): No library found for -lgdi32
        Win32: Test code failed: Can’t link/include ‘windows.h’, ‘gdi32′
        Writing Makefile for Imager::plugins
        Writing Makefile for Imager

        Libraries found:
        FT2
        GIF
        JPEG
        PNG
        TIFF
        Libraries *not* found:
        T1
        Win32

  3. flatline3 says:

    I forgot to mention — you can use the -v flag with Makefile.PL to see the compiler command and output for the failure.

  4. flatline3 says:

    As an aside, if you’ll forgive my leaving a mess on your post, this is why the homebrew folks drive me up the wall. There’s a lot of noise about how much X (X=MacPorts, X=!Ruby, etc) “sucks”, but not much time spent on reasoned discussion or careful consideration. Its frustrating that the initial response was “replace it with homebrew!”, especially given that the only reason homebrew worked is because they haven’t updated their copy of giflib to the latest release yet.

    • earino says:

      Are you kidding? No forgiveness necessary! This has been a great technical discussion and I’ve learned a bunch! Thank *you* for taking the time to comment on here!

    • rsanchezsaez says:

      earino: I think you should edit the original post and leave note explaining that it’s a good idea to read the comments for further discussion. Otherwise, people might read your post (which ranks high for the “macports vs homebrew” search) and leave with the impression that MacPorts is a crappy mess, which it is not. ;-)

  5. Much like MacPorts, you can specify the version of giflib you want to install:

    (mistercjr 9:18PM) brew versions giflib
    4.1.6 git checkout ac20448 /usr/local/Library/Formula/giflib.rb
    4.2.0 git checkout bad8e1f /usr/local/Library/Formula/giflib.rb

    I haven’t worked with giflib before, so I’m not sure if version 4.2.0 needs the patch.

  6. Robert Reiz says:

    I don’t like MacPorts very much. Every time I have to install something via MacPorts it takes forever. it is super slow. And sometimes I have problems with dependencies.
    I tried now Homebrew and I like it. It is much faster and I had much less problems with Homebrew than with MacPorts.

  7. FYI, the new command to install Homebrew is
    /usr/bin/ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”

  8. All is well with Homebrew until you have to install multiple versions of the same package…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s