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

前端 未结 30 1478
深忆病人
深忆病人 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:18

    Under CentOS 6.5 (Squeeze) I created a file:

    $ sudo touch /etc/profile.d/psql.sh
    

    with content:

    pathmunge /usr/pgsql-9.3/bin
    

    Note here, you should set your PostgreSQL path with the pg_config file. You can find this with the command:

    $ sudo find / -iname pg_config
    

    Save the file:

    $ sudo chmod +x /etc/profile.d/ruby.sh
    

    and try to execute your command again.

    Note: Anytime you change the Bash configuration - changing the profile.d configuration - you should reload Bash.

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

    For AltLinux the package postgresqlx.x-devel (in my case postgresql9.5-devel) must be installed:

    apt-get install postgresql9.5-devel
    
    0 讨论(0)
  • 2020-11-22 08:19

    On Ubuntu, install the "libpq-dev" to get rid of this issue.

    sudo apt-get install libpq-dev
    
    0 讨论(0)
  • 2020-11-22 08:20

    I had the same problem on Mac OS, but I installed the PostgreSQL gem easily by using the following in a terminal:

    ARCHFLAGS="-arch x86_64" gem install pg
    

    (I installed PostgreSQL first with brew install postgresql.)

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

    On FreeBSD (9.1) the necessary package is /usr/ports/database/postgresql-server* which when installed will also install the required header file that makes the gem install of "pg" fail. This answer here helped me find the solution but the difference in package names required a bit of searching.

    Hopefully this helps someone avoid a bit of head scratching when searching for the "-dev" package on a FreeBSD system!

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

    On Mac OS X run like this:

    gem install pg -- --with-pg-config=***/path/to/pg_config***
    

    ***/path/to/pg_config*** is path to pg_config

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