How to Install Postgresql'S Pg Gem on Ubuntu

PostgreSQL gem pg was unable to install

I got the same error on Centos. By googling I found two commands to use:

  1. yum install postgresql-libs -- It gave me message saying, its already installed.
  2. yum install postgresql-devel -- It solved my error related to pg_config for installing the 'pg' .gem.

Hope it helps :)

apos wrote: on Ubuntu 14.04 install:

  1. apt-get install postgresql-server-dev-9.3 libpq-dev

Can't find the 'libpq-fe.h header when trying to install pg gem

It looks like in Ubuntu that header is part of the libpq-dev package (at least in the following Ubuntu versions:
11.04 (Natty Narwhal), 10.04 (Lucid Lynx), 11.10 (Oneiric Ocelot), 12.04 (Precise Pangolin), 14.04 (Trusty Tahr) and 18.04 (Bionic Beaver)):

...
/usr/include/postgresql/libpq-fe.h
...

So try installing libpq-dev or its equivalent for your OS:

  • For Ubuntu/Debian systems: sudo apt-get install libpq-dev
  • On Red Hat Linux (RHEL) systems: yum install postgresql-devel
  • For Mac Homebrew: brew install postgresql
  • For Mac MacPorts PostgreSQL: gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
  • For OpenSuse: zypper in postgresql-devel
  • For ArchLinux: pacman -S postgresql-libs


Related Topics



Leave a reply



Submit