rails install pg-impossible de trouver le ' libpq-fe.h en tête

$ sudo bundle install

Résultat

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (0.9.2.2) 
Using i18n (0.6.1) 
Using multi_json (1.3.6) 
Using activesupport (3.2.8) 
Using builder (3.0.4) 
Using activemodel (3.2.8) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.8) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.11) 
Using mail (2.4.4) 
Using actionmailer (3.2.8) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Using activerecord (3.2.8) 
Using activeresource (3.2.8) 
Using bundler (1.2.1) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.7.5) 
Using rdoc (3.12) 
Using thor (0.16.0) 
Using railties (3.2.8) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.1.3) 
Installing pg (0.14.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.8 extconf.rb 
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.8
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config

Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.14.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.

Je suis faire $ gem install pg -v '0.14.1', Mais ce n'est pas de l'aide

Mon Gemfile

source 'https://rubygems.org'

#gem 'rails', '3.0.9'

#gem 'sqlite3', '1.3.6', :group => :development


gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'


gem 'sqlite3'
gem 'pg'
gem 'taps'

gem 'json'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'


#group :production do
  #gem 'pg'
#end
#group :development do
  #gem 'sqlite3'
#end

Gem_make.hors

/usr/bin/ruby1.8 extconf.rb 
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.8
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config

Mkmf.log

find_executable: checking for pg_config... -------------------- yes

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

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

"gcc -E -I. -I/usr/lib/ruby/1.8/i686-linux -I. -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -I -fno-strict-aliasing -g -g -O2  -fPIC    conftest.c -o conftest.i"
conftest.c:1:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include <libpq-fe.h>
/* end */

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

Aidez-moi s'il vous plaît. Merci.

Désolé pour ce texte. Votre message n'a pas beaucoup de contexte pour expliquer les sections de code; Veuillez expliquer votre scénario plus clairement.

44
demandé sur Michael Durrant 2012-10-26 15:27:37

11 réponses

Faites simplement ceci

$ sudo apt-get install libpq-dev
103
répondu Arthur Yakovlev 2012-10-26 12:01:48

Ceci est répondu dans impossible de trouver le ' libpq-fe.en-tête h lorsque vous essayez d'installer pg gem

Selon votre environnement:

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

Puis exécutez gem install pg à nouveau

32
répondu Phil 2017-05-23 12:18:14

Essayez ceci:

  1. brew installer postgresql
  2. gem installer pg
  3. installation groupée
14
répondu Karol 2013-11-04 13:46:11

Sur les systèmes Fedora/RHEL, cela a fait l'affaire:

sudo yum install libpqxx-devel
12
répondu nicolasochem 2015-03-11 05:04:17

Sur Mac OS X, exécutez comme ceci:

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

***/path/to/pg_config*** est le chemin vers pg_config

4
répondu Jiemurat 2014-01-08 09:39:09

Essayez ceci:

sudo apt-get install libpq-dev
gem install pg 

Ce serait des œuvres!

1
répondu Javid Dadashkarimi 2013-06-22 11:34:08

Sur mac assurez-vous que votre postgres est lié. Vous pouvez le faire par

brew link --overwrite postgresql

Cela a résolu le problème pour moi.

1
répondu Ashkinas 2016-05-03 17:14:54

J'ai eu ce problème avec un serveur Jenkins sur Amazon AMI.

$ pg_config | grep VERSION
VERSION = PostgreSQL 9.4.9

Ensuite, en fonction de la version dont vous avez besoin, vous pouvez installer la lib requise

$ 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

, Alors vous pouvez simplement installer la version correspondante, dans mon cas pour la version 9.4:

sudo yum install postgresql94-devel
1
répondu Justin Fortier 2016-12-08 22:25:11

Cela a fonctionné pour moi:

sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
0
répondu rassom 2015-12-27 01:08:26

J'utilise Ubuntu-16. Et j'utilise la méthode montrée ici: https://www.postgresql.org/download/linux/ubuntu / pour installer postgresql-9.6; Et j'utilise "sudo apt-get install libpq-dev" pour installer le devlib.Mais Il ne peut toujours pas de travail. J'utilise donc la méthode ln pour établir un lien souple, le voici : sudo ln -s /usr/include/postgresql/libpq-fe.h /usr/include/; sudo ln -s /usr/include/postgresql/postgres_ext.h /usr/include/ Et je résous enfin le problème.

0
répondu lxc 2017-07-26 16:40:50

brew install postgresql ça a marché pour moi.

L'Installation de postgresql donnait une autre erreur

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

Cette erreur a été corrigée en donnant accès aux répertoires mentionnés à l'utilisateur actuel

sudo chown -R $(whoami) (path)

0
répondu defcon 2018-10-05 22:45:10