ruby - How to install PostgreSQL's pg gem on Ubuntu?

ID : 10030

viewed : 24

Tags : rubypostgresqlpgruby

Top 5 Answer for ruby - How to install PostgreSQL's pg gem on Ubuntu?

vote vote


You need install the postgreSQL dev package with header of PostgreSQL

sudo apt-get install libpq-dev 
vote vote


After reading and thrashing around for 2 days, and trying many things found in other notes the following single line was the cure for me on Ubuntu Lucid 10.04 mixed with some Maverick packages and RVM (ruby 1.9.2-p290, rvm 1.10.2 rubygems 1.8.15, rails 3.0.1, postgres 8.4.10) :

gem install pg  --   --with-pg-lib=/usr/lib    

the result:

Building native extensions.  This could take a while...   Successfully installed pg-0.13.1   1 gem installed   Installing ri documentation for pg-0.13.1...   Installing RDoc documentation for pg-0.13.1...   

{yea - finally success} !! !note that the output from running pg_config lacks the item -lpq in the LIBS variable on my Ubuntu / Postresql install!!

and why the switch from pq to pg in certain places -- confusing to newbie ??

the thing I still do not understand is the double set of -- and --with(option but I'm way beyond my depth anyway

vote vote


In Ubuntu this works for me, I hope help you:

sudo apt-get install libpq-dev 


gem install pg  --   --with-pg-lib=/usr/lib  
vote vote


I'm on Ubuntu 12.10 and running this command:

apt-get install libpq-dev 

helped me - after that ran gem install pg -v "0.14.1", and all good now

vote vote


Installing libpq-dev did not work for me. I also needed to install build-essential

sudo apt-get install libpq-dev build-essential 

Top 3 video Explaining ruby - How to install PostgreSQL's pg gem on Ubuntu?