74

WhenI run (root として)

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config

次の出力が得られます。

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Building native extensions.  This could take a while...
Successfully installed pg-0.12.0
1 gem installed
Installing ri documentation for pg-0.12.0...
Installing RDoc documentation for pg-0.12.0...
#-> 

bundle install を実行すると:

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
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
--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/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
--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/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-    0.12.0 for inspection.
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out
An error occured while installing pg (0.12.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling.

/usr/pgsql-9.1/include/libpq-fe.h に libpq-fe.h をインストールしました。だから、私は試しました

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go. 

どんな助けでも大歓迎です。

また、postgresql91-devel と ruby​​-devel をインストールしました。CentOS 6 を実行しています。

4

18 に答える 18

188

実行する前にこれを実行してみましたbundle installか?

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

http://bundler.io/v1.3/bundle_config.htmlを参照してください

于 2012-02-10T21:32:55.050 に答える
21

誰かが macports を使用して postgres をインストールし、pg_config を見つけるのに問題がある場合は、これを試してください:

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config

これが誰かの時間を節約するのに役立つことを願っています。乾杯!

于 2012-04-23T08:21:42.690 に答える
14

pg_config の場所がわからない場合、Linux または Mac を使用していると仮定すると、次のコマンドを実行できます。

which pg_config

これは ==> を返します /usr/pgsql-9.1/bin/pg_config

このパスを次のように使用します

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

今すぐ完了bundle install

于 2016-02-02T05:42:04.027 に答える
7

同じ問題がありましたが、libpq-dev をインストールすることで修正されました。

参照: https://bitbucket.org/ged/ruby-pg/issue/83/help-gem-install-pg-failed-on-opensuse-103

于 2013-01-22T16:37:18.590 に答える
6

コピーペースト:

bundle config build.pg --with-pg-config=`which pg_config` && bundle

詳細:

詳細については、以下をご覧ください。

最初に行うべきことは、Postgres に付属の 'pg_config' ツールがパスにあることを確認することです。そうでない場合、またはパスの最初にあるものが、ビルド対象の Postgres と一緒にインストールされたものでない場合は、–with-pg-config オプションを使用してそのパスを指定できます。

ソース: https://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/extconf.rb#L27

于 2016-12-08T16:31:36.530 に答える
4

pg_config がインストールされているが、どのパスにもない場合、このエラーが発生する可能性があります。~/.bashrc の PATH env に追加できます。

例えば。

export PATH=${PATH}:/usr/pgsql-9.2/bin
于 2013-01-14T16:35:47.740 に答える
4

Postgres gem が Postgres 構成ファイルを見つけることができません。それがどこにあるかを伝える必要があります。私の意見では、これに対する最も楽しい解決策は、Brew と MacPorts をスキップして Postgres アプリを使用することです。ここからダウンロードしてインストールします。

http://postgresapp.com/

bin フォルダーをパスに追加します。

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

これを ~/.bash_profile に追加することもできます

次に、gem をインストールします。

gem install pg

スムーズに進むはずです。

于 2013-11-05T14:26:32.780 に答える
3

OS Xで私のものを修正するには、これを行う必要がありました:

export PATH=/opt/local/lib/postgresql84/bin/:$PATH

そして、私はすでにこれを自分の道に持っていたという事実にもかかわらず、それをしなければなりませんでした:

[user@foo ~] which psql84
/opt/local/bin/psql84

[user@foo ~] ls -altrh /opt/local/bin/psql84 
lrwxr-xr-x  1 root  admin    36B Dec  7 02:15 /opt/local/bin/psql84 ->  /opt/local/lib/postgresql84/bin/psql

この問題で別の Mac ユーザーに役立つことを願っています。

于 2013-01-29T20:38:27.807 に答える
1

Mac で postgresapp を使用する場合は、http://postgresapp.com/documentation/cli-tools.htmlドキュメントを読み、$PATH を構成してください。この前に、もう一度バンドル インストールを実行してみてください。

于 2016-03-22T02:44:17.317 に答える
0

OSX では、最初に pg をインストールします。

brew install postgresql

次に、gem をインストールします。

gem install pg --source 'https://rubygems.org/'

その後、実行できますbundle install

于 2019-01-07T16:16:16.400 に答える
0
gem install pg -v '0.17.1'

私のためにトリックをしました。

于 2015-03-19T05:12:16.183 に答える