Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg 1.0.0 `fatal error: 'libpq-fe.h' file not found`

An error occurred while installing pg (1.0.0), and Bundler cannot continue

I have an issue with the bundle install and cannot complete the installation.

What can I do to finish the bundle?

  find_executable: checking for pg_config... -------------------- no

    --------------------

    find_header: checking for libpq-fe.h... -------------------- no

    "clang -o conftest -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. -I/Users/leotyndall/.rbenv/versions/2.4.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib  -fstack-protector -L/usr/local/lib     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc "
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2: 
    3: int main(int argc, char **argv)
    4: {
    5:   return 0;
    6: }
    /* end */

        "clang -E -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 - 
             I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby- 
         2.4.0/ruby/backward - 
         I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. - 
         I/Users/leotyndall/.rbenv/versions/2.4.2/include  -D_XOPEN_SOURCE - 
         D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno- 
         error=shorten-64-to-32  -pipe  conftest.c -o conftest.i"
         conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
         #include <libpq-fe.h>
             ^~~~~~~~~~~~
         1 error generated.
         checked program was:
         /* begin */
         1: #include "ruby.h"
         2: 
         3: #include <libpq-fe.h>
        /* end */

    --------------------


     extconf failed, exit code 1


        An error occurred while installing pg (1.0.0), and Bundler cannot continue.
        Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.
like image 457
Leo Tyndall Avatar asked May 10 '18 11:05

Leo Tyndall


People also ask

What is Libpq Fe H?

* libpq-fe.h. * This file contains definitions for structures and. * externs for functions used by frontend postgres applications. *

Where can I find Libpq?

Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package. You can download it from the PostgreSQL Downloads page.


2 Answers

Try installing libpq-dev or its equivalent for your OS:

  • For Ubuntu 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
like image 142
NARKOZ Avatar answered Sep 17 '22 15:09

NARKOZ


For macos, the above answers did not work or were not practical for me. I didn't want to install all of postgres.

$ brew install libpq
$ bundle config --local build.pg --with-opt-dir="/usr/local/opt/libpq"
$ bundle install

Reference: https://michaelrigart.be/install-pg-ruby-gem-without-postgresql/

like image 40
Michael Avatar answered Sep 19 '22 15:09

Michael