rails install pg – Der Header „libpq-fe.h“ kann nicht gefunden werden

Lesezeit: 6 Minuten

Benutzeravatar von Arthur Yakovlev
Arthur Jakowlew

$ sudo bundle install

Ergebnis

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.

Ich bin gemacht $ gem install pg -v '0.14.1' Aber das ist keine Hilfe

Meine 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.out

/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 */

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

Hilf mir bitte. Vielen Dank.

Entschuldigung für diesen Text. Ihr Beitrag enthält nicht viel Kontext, um die Codeabschnitte zu erklären. Bitte erkläre dein Szenario genauer.

  • Wie hast du PostgreSQL installiert?

    – Stefan

    26. Oktober 2012 um 11:32 Uhr

  • mögliches Duplikat von Can’t find the PostgreSQL client library (libpq)

    – Skolima

    26. Oktober 2012 um 12:49 Uhr

  • mögliches Duplikat von Can’t find the ‘libpq-fe.h header when try to install pg gem

    – Bilderstürmer

    25. Januar 2014 um 5:46 Uhr

Mach das einfach

$ sudo apt-get install libpq-dev

  • Ich habe versucht, das unter Ubuntu 14.04 zu tun, aber es gab mir Folgendes: ” libpq-dev : Depends: libpq5 (= 9.3.4-1) but 9.3.10-0ubuntu0.14.04 is to be installed “

    – Michael Lafayette

    13. Januar 2016 um 13:35 Uhr


  • Aber dann, wenn ich versuche, libpq5 zu installieren, sagt es “libpq5 ist bereits die neueste Version.”

    – Michael Lafayette

    13. Januar 2016 um 13:40 Uhr

  • PostgreSQL-Version ist: psql –version: psql (PostgreSQL) 9.3.10. PostgreSQL 9.3.10 auf x86_64-unknown-linux-gnu, kompiliert von gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-Bit

    – Michael Lafayette

    13. Januar 2016 um 13:40 Uhr

  • Brillant! Die Anwendung, die ich kompilierte, benötigte auch den Pfad zu libpq-fe.h explizit anzugeben, mit --with-cflags=-I/usr/include/postgresqlfalls es jemand anderem auch so geht.

    – Ben Johnson

    16. November 2016 um 15:07 Uhr

  • Das hat am Ende für mich funktioniert, oder zumindest die Mac-Version davon brew install libpq. musste ich dann auch brew link --force libpq um das zu bekommen gem install pg erfolgreich abzuschließen.

    – Scott Schupbach

    28. Januar 2020 um 21:46 Uhr

Benutzeravatar von Phil
Phil

Dies wird in Kann den Header „libpq-fe.h“ beim Versuch, pg gem zu installieren, nicht finden beantwortet

Abhängig von Ihrer Umgebung:

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

Dann renne gem install pg wieder

  • Ich habe versucht, das unter Ubuntu 14.04 zu tun, aber es gab mir Folgendes: ” libpq-dev : Depends: libpq5 (= 9.3.4-1) but 9.3.10-0ubuntu0.14.04 is to be installed “

    – Michael Lafayette

    13. Januar 2016 um 13:41 Uhr

  • Aber dann, wenn ich versuche, libpq5 zu installieren, sagt es “libpq5 ist bereits die neueste Version.” Gleiches gilt für PostgreSQL

    – Michael Lafayette

    13. Januar 2016 um 13:42 Uhr

  • PostgreSQL-Version ist: psql –version: psql (PostgreSQL) 9.3.10. PostgreSQL 9.3.10 auf x86_64-unknown-linux-gnu, kompiliert von gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-Bit

    – Michael Lafayette

    13. Januar 2016 um 13:42 Uhr

  • Hey Michael, ich bin mir nicht sicher, ob ich deine Frage beantworten kann, weil ich mit Ubuntu nicht vertraut bin, aber vielleicht möchtest du dir die Antwort von Michael Durrant hier ansehen: stackoverflow.com/a/8887801/2484523

    – Phil

    19. Januar 2016 um 22:12 Uhr

  • Gearbeitet auf Red Hat EL7. Bei einer Perl-Installation von DBD::Pg fehlte mir die Header-Datei.

    – Markus

    19. Februar 2018 um 14:03 Uhr


Versuche dies:

  1. brauen postgresql installieren
  2. gem install pg
  3. Paket installieren

Benutzeravatar von nicolasochem
Nikolauschem

Auf Fedora/RHEL-Systemen hat dies den Zweck erfüllt:

sudo yum install libpqxx-devel

  • ALSO: Ubuntu
  • Sprachprogrammierung: C

$ sudo apt-get install libpq-dev

In meinem Fall habe ich den Verzeichnispfad falsch angegeben. So:

Aus: gcc -o lib_version lib_version.c -I/usr/include/postgresql -lpq -std=c99

Zu: gcc -o lib_version lib_version.c -I /usr/include/postgresql -lpq -std=c99

GL

Zum Alpines LinuxDu kannst hinzufügen libpq-fe.h mit:

apk add postgresql-dev

Für Amazon Linux (AWS):

sudo yum install postgresql-devel

Führen Sie dann Ihren Befehl erneut aus

1422270cookie-checkrails install pg – Der Header „libpq-fe.h“ kann nicht gefunden werden

This website is using cookies to improve the user-friendliness. You agree by using the website further.

Privacy policy