I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg
gem. It gives me the following error:
I finally solved this problem, but not using the previously described methods.
Using brew install postgresql
, I find out that it had already been installed, but not linked.
Find out where PostgreSQL is installed, and delete it,
Then brew install postgresql
again,
brew link postgresql
gem install pg
In my case it was package postgresql-server-dev-8.4
(I am on Ubuntu 11.04 (Natty Narwhal), 64 bits).
I had the same issue on Amazon Linux. I could find the header libpq-fe.h
, but somehow it didn't work.
It came from the different versions of the packages that were installed through the different users on the machine. PostgreSQL 9.2 and PostgreSQL 9.3 were installed. So, make sure of your PostgreSQL version before including the libraries.
For me, the magic command line was:
sudo yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel
Source: An almost idiot's guide to install PostgreSQL 9.3, PostGIS 2.1 and pgRouting with Yum
On CentOS,I installed libpq-dev package
using below command
yum install postgresql-devel
Executing gem install pg
returned the same error as "No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config
".
Installing the gem as below solved my problem
gem install pg -- --with-pg-config=/usr/pgsql-x.x/bin/pg_config
I recently upgraded to Mac OS X v10.10 (Yosemite) and was having difficulty building the pg
gem.
The error reported was the typical:
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
My solution was to gem uninstall pg
and then bundle update pg
to replace the gem with the latest. I did run brew update; brew upgrade
after the Yosemite install to get the latest versions of packages I had installed previously.
I had also tried doing gem install libpq-dev
, but I received this error:
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
However I found that installing with sudo apt-get
(which I try to avoid using with Ruby on Rails) worked, i.e.
sudo apt-get install libpq-dev
# or
apt-get install postgres-server-dev-{pg.version}
# for postgresql 9.4 on Ubuntu 14.04
then I was able to do
gem install pg
without issues.