My cap production deploy is failing on nokogiri installation on an Ubuntu 12.04 box:
DEBUG [6f355ce8]    Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
DEBUG [6f355ce8]    Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
DEBUG [6f355ce8]    *** extconf.rb failed ***
DEBUG [6f355ce8]    Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
I checked said logs and it mentions not finding a C compiler. I tried to install the dependencies for ubuntu on the nokogiri site and the system says they are already installed.
I also tried gem install nokogiri -v '1.6.1' on the server and it succeeds with no issues, gem list shows it installed on the server.  
I found a similar question that suggested adding this line to the production.rb
set :bundle_env_variables, { 'NOKOGIRI_USE_SYSTEM_LIBRARIES' => 1 }
Which changes the error to be a bit more specific:
DEBUG [1e93b004]    /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
DEBUG [1e93b004]    You have to install development tools first.
But trying to install them via:
sudo apt-get install libxslt-dev libxml2-dev
says everything is already installed --and again, nokogiri installs fine outside of the deploy task.