I'm trying to develop in Ruby on Rails using PostgreSQL locally, so I'm trying to install the pg gem. On Ubuntu 12.04. In terminal, I typed in:
gem install pg -v '0.12.2'
Which throws the following error:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/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)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1 for inspection.
Results logged to /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1/ext/gem_make.out
Interestingly, adding a sudo to the command works:
$ sudo gem install pg -v '0.12.2'
Building native extensions. This could take a while...
Successfully installed pg-0.12.2
1 gem installed
Btw I had to run "sudo apt-get install ruby1.9.1-dev" to get the above command to work. But I still can't do any development because "bundle install" will not work (and keeps telling me to run 'gem install pg -v '0.12.2')
I have a feeling "gem install pg" is getting tripped up at
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
but, as a complete noob to Ubuntu and RoR, I have no idea why. Maybe my search skills stink too, because I haven't been able to find a solution to my particular case. Hopefully there's a fix?
Thanks!
libpq-dev
is installed? I've posted an answer that explains how to do so. – Uldalibpq-dev
do you have installed? – Ulda$ sudo apt-get update
,$ sudo apt-get install postgresql libpq-dev build-essentials git-core curl
,$ curl -L https://get.rvm.io | bash -s stable --ruby
, and$ gem install pg -v
0.12.2` with no error (also, I installed the latest version of thepg
gem, v0.14.1, without error; you may want to see if you can use the newest version, not that it will necessarily fix your issue). – Uldalibpq-dev
?$ sudo apt-get autoremove postgresql libpq-dev
if you installed using apt. While you're at it, you should consider using the latest version of Postgres:$ sudo add-apt-repository ppa:pitti/postgresql
,$ sudo apt-get update
,$ sudo apt-get install postgresql libpq-dev
. Note: All of this assumes you're not root – Ulda