1

I have read every article I can find on this but seem to have the problem despite having tried the various recommendations.

I am using RVM on Ubuntu 12.10. All my other gems are installing fine but the pg gem is failing with:

Can't find the PostgreSQL client library (libpq)

I am using the postgresql repository described here: http://wiki.postgresql.org/wiki/Apt

I have used apt-get to install the following:

postgresql-9.1
postgresql-client-9.1
postgresql-server-dev-9.1
libpq-dev
build-essential
pgadmin3

This is a clean install of Ubuntu 12.10 just loaded and updated today.

I installed ruby 1.9.3-p392 via RVM.

pg_config output:

    BINDIR = /usr/lib/postgresql/9.1/bin
DOCDIR = /usr/share/doc/postgresql-doc-9.1
HTMLDIR = /usr/share/doc/postgresql-doc-9.1
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/9.1/server
LIBDIR = /usr/lib
PKGLIBDIR = /usr/lib/postgresql/9.1/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/9.1/man
SHAREDIR = /usr/share/postgresql/9.1
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/9.1/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-krb5' '--with-gssapi' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-ldap' '--with-tclconfig=/usr/lib/tcl8.5' '--with-tkconfig=/usr/lib/tk8.5' '--with-includes=/usr/include/tcl8.5' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/9.1/man' '--docdir=/usr/share/doc/postgresql-doc-9.1' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/9.1' '--bindir=/usr/lib/postgresql/9.1/bin' '--libdir=/usr/lib/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-debug' '--disable-rpath' '--with-ossp-uuid' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie' 'CPPFLAGS=-D_FORTIFY_SOURCE=2 -DLINUX_OOM_ADJ=0' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
CC = gcc
CPPFLAGS = -D_FORTIFY_SOURCE=2 -DLINUX_OOM_ADJ=0 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.5
CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g
CFLAGS_SL = -fpic
LDFLAGS = -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgport -lxslt -lxml2 -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm 
VERSION = PostgreSQL 9.1.8
n8gard
  • 1,870
  • 8
  • 26
  • 41
  • it's a very common error. Can you run pg_config? – kasperite Mar 19 '13 at 05:31
  • I've added pg_config output to the question. Strangely, I used an answer (http://stackoverflow.com/questions/8814924/gem-install-pg-can-not-bind-to-libpq/8874260#8874260) to get this working in a very hacky way. I issued the command: 'cp -R ~/.rvm/usr/lib ~/.rvm/usr/lib_rvm' and the gem installed. – n8gard Mar 19 '13 at 17:07

1 Answers1

0

Try installing PostgreSQL developmenmt headers:

sudo apt-get install libpq-dev

See also How to install PostgreSQL's pg gem on Ubuntu?

Community
  • 1
  • 1
Gonzalo Matheu
  • 8,984
  • 5
  • 35
  • 58