Installing the PostgreSQL gem with 'gem pq' fails with ERROR: Failed to build gem native extension
If you are using Ubuntu try to install following lib file
sudo apt-get install libpq-dev
and then gem install pg
worked for me.
for those who reached this by google searchif libpq-dev didnt workor threw another errorsi hade the same problemtry upgrading your systemand get the ruby div-kit
sudo apt-get updatesudo apt-get upgradesudo apt-get install ruby1.9.1-dev
then rebootafter this just try again
...
You have to do this
sudo apt-get install libgmp-dev libpq-dev
and then
gem install pg