Install problems: nokogiri on Mac OSx Mountain Lion

For some reason I cannot install Nokogiri on my MacBook for traveling.

Short output from gem install nokogiri is:

Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin12/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/jseidel/.rvm/gems/ruby-1.9.3-p327@rails3213/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin12/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin12/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Users/jseidel/.rvm/gems/ruby-1.9.3-p327@rails3213/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin12/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

However, I use MacPorts and it says that’s already installed:

port installed | grep lib
libxml @1.8.17_0 (active)
libxml2 @2.9.1_0 (active)

Is it maybe getting confused because both libxml and libxml2 are installed or is there something else going on?

I’ve followed the installation instructions at Nokigiri Installation and that doesn’t help.

Don’t mean to start a flame war here if anyone is a huge MacPorts partisan, but after years of frustration with MacPorts over issues like this (which I think is the compiler not being able to find the right location of libxml2, you may want to specify it with a command line flag or environment variable), I moved to use Homebrew and many fewer issues with these kinds of compilation obstacles.

If there’s a MacPorts solution other than manually specifying the path to libxml2, that would at least spare you the time of having to uninstall MacPorts and reinstall everything with Homebrew (Homebrew and MacPorts do not coexist well).

Sorry, but I’ve tried homebrew and they didn’t have the libraries I wanted so I’m sticking with MacPorts :=)

I’d be happy to learn how to set the command line flags with a gem install, though.