rails install pg - Can't find the 'libpq-fe.h header

孤街浪徒 提交于 2019-11-29 22:46:33

Just make this

$ sudo apt-get install libpq-dev
Phil

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

Depending on your environment:

  • Mac: brew install postgresql
  • Ubuntu: sudo apt-get install libpq-dev
  • RHEL: yum install postgresql-devel

Then run gem install pg again

Try this:

  1. brew install postgresql
  2. gem install pg
  3. bundle install
nicolasochem

On Fedora/RHEL systems this did the trick:

sudo yum install libpqxx-devel

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

I had this issue with a Jenkins server on Amazon AMI.

$ pg_config | grep VERSION
VERSION = PostgreSQL 9.4.9

Then depending on which version you need you can install the required lib

$ sudo yum list postgresql* | grep devel
postgresql92-devel.x86_64               9.2.18-1.59.amzn1          @amzn-main
postgresql94-devel.x86_64               9.4.9-1.67.amzn1           @amzn-main
postgresql8-devel.x86_64                8.4.20-5.52.amzn1          amzn-main
postgresql93-devel.x86_64               9.3.14-1.62.amzn1          amzn-main
postgresql95-devel.x86_64               9.5.4-1.71.amzn1           amzn-main

Then you can just install the corresponding version, in my case for version 9.4:

sudo yum install postgresql94-devel

For Amazon Linux:

sudo yum install postgresql-devel

then run your command again

try this:

sudo apt-get install libpq-dev
gem install pg 

it would be works!

On mac make sure your postgres is linked. You can do it by

brew link --overwrite postgresql

This fixed the issue for me.

rassom

This worked for me:

sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config

I use Ubuntu-16. And I use the method showed here:https://www.postgresql.org/download/linux/ubuntu/ to install postgresql-9.6; And I use "sudo apt-get install libpq-dev" to install the devlib.But It still can't work. So I use the method ln to establish soft link, here it is : sudo ln -s /usr/include/postgresql/libpq-fe.h /usr/include/; sudo ln -s /usr/include/postgresql/postgres_ext.h /usr/include/ And I solve the problem at last.

brew install postgresql worked for me.

Installation of postgresql was giving another error

Error: The following directories are not writable by your user: /usr/local/lib/pkgconfig /usr/local/share/info /usr/local/share/man/man3

This error was fixed by giving access to the mentioned directories to the current user

sudo chown -R $(whoami) (path)

For Alpine Linux, you can add libpq-fe.h with:

apk add postgresql-dev
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!