3

I am using Ubuntu 12.10 64-bit and I have following packages installed :

dpkg --get-selections | grep postgre

output:

postgresql
postgresql-9.1
postgresql-client
postgresql-client-9.1
postgresql-client-common
postgresql-common
postgresql-contrib
postgresql-contrib-9.1
postgresql-server-dev-9.1
postgresql-server-dev-all
libpq-dev
libpq5

rvm 1.17.9

ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]

I am not able to install pg gem I am getting following error :

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/vedarthk/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)

I have also tried following commands but the output is same as above :

gem install pg -- --with-pg-include=/usr/include/postgresql/libpq --with-pg-lib=/usr/lib/postgresql/9.1/lib


gem install pg -- --with-pg-include=/usr/include/postgresql --with-pg-lib=/usr/lib/postgresql/9.1/lib
vedarthk
  • 1,253
  • 1
  • 14
  • 34
  • Try installing `build-essential` package as mentioned here: http://stackoverflow.com/a/12269483/429758. The other answers in that thread - particularly the ones about `rvmsudo` - might help as well. – Prakash Murthy Jan 23 '13 at 16:35
  • I did do that but `build-essential` is already installed and I have latest version. – vedarthk Jan 24 '13 at 09:41

3 Answers3

2

Try installing PostgreSQL development headers:

sudo apt-get install libpq-dev

Gonzalo Matheu
  • 8,984
  • 5
  • 35
  • 58
  • Duplicated http://stackoverflow.com/questions/3116015/how-to-install-gem-pg-on-ubuntuXX – Gonzalo Matheu Nov 06 '13 at 19:22
  • @vedarthk already indicates that they've this package installed. This can't be the answer. (And therefore is not a duplicate question) – Kurt Feb 07 '20 at 16:52
0

Try - $ sudo apt-get install ruby-dev

sudo gem install pg won't work has that solution and it worked for me.

Community
  • 1
  • 1
quantum_random
  • 458
  • 2
  • 7
  • I am using rvm, using `sudo apt-get install ruby-dev` gives me an error `ruby-dev : Depends: ruby1.9.1-dev (>= 1.9.3.194-1) but it is not going to be installed` – vedarthk Feb 06 '13 at 09:54
0

I had a similar problem on RHEL 6.4, the following worked for me:

gem install /opt/redmine/vendor/cache/pg-0.18.4.gem --local -- --with-pg-dir=/usr/pgsql-9.4/

I setup PostgreSQL from their own repos.

Bruno Medeiros
  • 2,251
  • 21
  • 34