Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to build pg gem

I have:

  • Ubuntu 11.10
  • Postgres 8.4
  • libpq-dev, build-essential installed
  • ruby 1.9.2 and rails 3.2.1 install via rvm

However, pg gem fails to build, saying that:

checking for pg_config... yes
Using config values from /usr/lib/postgresql/8.4/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)
*** extconf.rb failed ***

I understant that this problem was asked dozen of times, but I googled like 2 days, and tried all the solutions I encoutered, and still this gem fails to build.

Any ideas?

like image 883
UncleLaz Avatar asked Mar 01 '26 11:03

UncleLaz


1 Answers

Today I encountered a very similar problem on an Ubuntu 10.04. After trying to get the pg installed for half a day, I decided to just install a more recent version of postgresql manually - which solved the problem for me.

Here is what I did:

1) Obtain the postgresql sources from their website. Since I deploy my rails applications to heroku and they say that they use version 9.0 of postgresql atm, I downloaded

http://ftp.postgresql.org/pub/source/v9.0.6/postgresql-9.0.6.tar.gz

2) Unpack, then follow the instructions in the INSTALL file. Note that 'su' is to be replaced by 'sudo su' in Ubuntu. After that, you have a postgresql server installed at /usr/local/pgsql/.

3) If you already had a system user named 'postgres', you might want to change its home directory to the new postgres installation. And you might want to add /usr/local/pgsql/bin to your PATH. Maybe uninstalling the postgresql-8.4 through apt-get before installing the 9.0 version from sources would be a good idea, I did not try that.

hth

like image 163
Raffael Avatar answered Mar 03 '26 23:03

Raffael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!