109
$ sudo bundle install

結果

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.

私は作っていますが$ gem install pg -v '0.14.1'、これは助けにはなりません

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

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

お願い助けて。ありがとうございました。

このテキストでごめんなさい。あなたの投稿には、コードセクションを説明するためのコンテキストがあまりありません。シナリオをより明確に説明してください。

4

16 に答える 16

226

これを作るだけ

$ sudo apt-get install libpq-dev
于 2012-10-26T12:01:48.613 に答える
81

これは、pggemをインストールしようとしたときに'libpq-fe.hヘッダーが見つかりませんで答えられます

環境に応じて:

  • マック: brew install postgresql
  • Ubuntusudo apt-get install libpq-dev
  • RHELyum install postgresql-devel

その後、gem install pg再度実行します

于 2015-11-23T17:31:46.673 に答える
19

これを試して:

  1. brew install postgresql
  2. gem install pg
  3. バンドルインストール
于 2013-11-04T13:46:11.747 に答える
17

Fedora / RHELシステムでは、これでうまくいきました。

sudo yum install libpqxx-devel
于 2015-02-01T05:14:42.233 に答える
15
  • SO:Ubuntu
  • 言語プログラミング:C

$ sudo apt-get install libpq-dev

私の場合、ディレクトリパスを間違っていました。それで:

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

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

GL

于 2019-10-05T22:06:04.093 に答える
8

Amazon Linux(AWS)の場合:

sudo yum install postgresql-devel

その後、コマンドを再度実行します

于 2019-04-03T08:17:39.250 に答える
8

Alpine Linuxの場合、次のコマンドを追加できますlibpq-fe.h

apk add postgresql-dev
于 2019-09-09T23:36:36.693 に答える
5

Mac OS Xでは、次のように実行します。

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

***/path/to/pg_config***pg_configへのパスです

于 2014-01-08T09:39:09.853 に答える
4

この問題は、AmazonAMIのJenkinsサーバーで発生しました。

$ pg_config | grep VERSION
VERSION = PostgreSQL 9.4.9

次に、必要なバージョンに応じて、必要なライブラリをインストールできます

$ 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

次に、対応するバージョン(私の場合はバージョン9.4)をインストールできます。

sudo yum install postgresql94-devel
于 2016-12-08T22:25:11.773 に答える
3

これは、centos7ディストリビューションにアプリをデプロイしているときにcapistranoを使用して発生していました。どうやらgemは正しい開発パッケージをインストールすることで解決できるいくつかのヘッダーファイルを必要としています。

実行して修正しsudo yum search postgres | grep devel、postgresのインストールに適したパッケージである10を見つけました。

次に、実行するだけでsudo yum install postgresql10-devel、eureka!

于 2019-10-14T05:22:06.077 に答える
2

これを試して:

sudo apt-get install libpq-dev
gem install pg 

それはうまくいくでしょう!

于 2013-06-22T11:34:08.153 に答える
2

Macでは、postgresがリンクされていることを確認してください。あなたはそれを行うことができます

brew link --overwrite postgresql

これで問題が解決しました。

于 2016-05-03T17:14:54.307 に答える
1

私はUbuntu-16を使用しています。そして、ここに示す方法を使用します:https ://www.postgresql.org/download/linux/ubuntu/ to install postgresql-9.6; そして、私"sudo apt-get install libpq-dev"はdevlibをインストールするために使用しますが、それでも機能しません。lnだから私はソフトリンクを確立 するための方法を使用します、ここにそれがあります: sudo ln -s /usr/include/postgresql/libpq-fe.h /usr/include/; sudo ln -s /usr/include/postgresql/postgres_ext.h /usr/include/ そしてついに問題を解決しました。

于 2017-07-26T16:40:50.147 に答える
1

brew install postgresql私のために働いた。

postgresqlのインストールで別のエラーが発生していました

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

このエラーは、現在のユーザーに上記のディレクトリへのアクセスを許可することで修正されました

sudo chown -R $(whoami) (path)

于 2018-10-05T22:45:10.143 に答える
0

これは私のために働いた:

sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
于 2015-12-27T00:20:50.227 に答える
0

Homebrewpostgresql経由でMacOSにインストールした場合

brew install postgresql@95 # 9.5 is the version needed in my project

pg_configあなたのバージョンによっては見つける必要があるかもしれませんlibpq

私のプロジェクトには古いバージョンのが必要でしpgた。

gem install pg -v '0.20.0' -- --with-pg config=/usr/local/Cellar/libpq/13.1/bin/pg_config
于 2021-02-07T22:16:09.430 に答える