3

I'm using/I want to use Postgresql as database, but when I type "bundle install" or "bundle update", I get this error, what do I do to fix this? :)

    Installing pg (0.17.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
    --without-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=/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib


Gem files will remain installed in /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1 for inspection.
Results logged to /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

Any suggestions?

Wayne Conrad
  • 103,207
  • 26
  • 155
  • 191
maverick
  • 800
  • 2
  • 13
  • 30

3 Answers3

6

Looks like you are missing pre-requisite libraries.

sudo apt-get install libpq-dev postgresql-devel

Then install pg

gem install pg
Pravin Mishra
  • 8,298
  • 4
  • 36
  • 49
  • I've tried using that command, but the terminal says: "sudo: apt-get: command not found" – maverick Dec 19 '13 at 09:16
  • apt-get is not installed on your system, I hope wget is installed on your system. run "wget http://mirror.pnl.gov/ubuntu//pool/main/a/apt/apt_0.9.7.7ubuntu4_amd64.deb" then "sudo dpkg -i apt_0.9.7.7ubuntu4_amd64.deb" – Pravin Mishra Dec 19 '13 at 09:20
  • expecting you have 64bit system. – Pravin Mishra Dec 19 '13 at 09:22
  • Hm... Nothing really happens. Still "command not found". Is there a special place where I'm suppose to install these commands? – maverick Dec 19 '13 at 09:45
  • check it out http://askubuntu.com/questions/295171/how-to-install-apt-get-package-manager – Pravin Mishra Dec 19 '13 at 10:21
  • You keep assuming that OP is using Ubuntu, but they clearly aren't if they don't have apt-get installed. – Jordan Mar 21 '14 at 05:14
5

For those on OS X, I recommend using home-brew to install:

brew install postgresql

More info at Homebrew's site, if you're not already a user, including how to set it up.

Bdebeez
  • 3,542
  • 3
  • 31
  • 32
1

in order to communicate with a PostgreSQL database backend you need the libpq-dev package.

sudo apt-get install libpq-dev 

then continue the package installation

gem install pg
errakeshpd
  • 2,544
  • 2
  • 28
  • 35