I was having trouble installing 0.10.1 version of therubyracer on Mountain Lion, because it depends on libv8  This is running Ruby 1.8.7.  Upgrading to 0.11 worked but that was failing on other machines too so for now we needed to stick with 0.10.1.

The solution was brilliantly documented here:

Note, if you use "sudo", but the option after the sudo:

sudo RUBYOPT=-rrubygems gem install therubyracer

Or if you just need libv8 for whatever reason:

sudo RUBYOPT=-rrubygems gem install libv8 -v ''