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

前端 未结 30 1432
深忆病人
深忆病人 2020-11-22 07:47

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:



        
相关标签:
30条回答
  • 2020-11-22 08:35

    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.

    1. Find out where PostgreSQL is installed, and delete it,

    2. Then brew install postgresql again,

    3. brew link postgresql

    4. gem install pg

    0 讨论(0)
  • 2020-11-22 08:36

    In my case it was package postgresql-server-dev-8.4 (I am on Ubuntu 11.04 (Natty Narwhal), 64 bits).

    0 讨论(0)
  • 2020-11-22 08:36

    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

    0 讨论(0)
  • 2020-11-22 08:38

    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
    
    0 讨论(0)
  • 2020-11-22 08:39

    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.

    0 讨论(0)
  • 2020-11-22 08:40

    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.

    0 讨论(0)
提交回复
热议问题