0

私は Mac OS X 10.8.2 を使用しているが、その後の問題に不満を感じて数時間前に再インストールした。

Homebrew をインストールしました。実行するbrew doctorと、 と表示されますYour system is raring to brew

コマンドライン ユーティリティを備えた最新の Xcode を使用しています。

Homebrew を使用して PostgreSQL をインストールしました。

steven$ ls /usr/local/Cellar/postgresql/9.2.1
COPYRIGHT           README              homebrew.mxcl.postgresql.plist  lib
INSTALL_RECEIPT.json        bin             include             share

steven$ psql --version
psql (PostgreSQL) 9.2.1
iMac-001EC20A3C44-5:9.2.1 steven$ which psql
/usr/local/bin/psql

gem 'pg'Gemfileを含む Rail アプリがありますが、gem をインストールできません。

steven$ bundle install
Fetching source index for http://rubygems.org/
Installing pg (0.14.1) with native extensions /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/installer.rb:482:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Using config values from /usr/pgsql-9.1/bin/pg_config
sh: /usr/pgsql-9.1/bin/pg_config: No such file or directory
sh: /usr/pgsql-9.1/bin/pg_config: No such file or directory
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

簡単に見つけられる pg_config と libpq を探しているようです。

steven$ ls /usr/local/Cellar/postgresql/9.2.1/bin
...     pg_config       ...
steven$ ls /usr/local/Cellar/postgresql/9.2.1/include
...     libpq           ...

だから私は考えることができるすべての構成オプションを渡そうとしましたが、どれもうまくいきません:

steven$ sudo gem install pg -- --with-pg-config="/usr/local/Cellar/postgresql/9.2.1/bin"
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin
Using config values from /usr/local/Cellar/postgresql/9.2.1/bin
sh: /usr/local/Cellar/postgresql/9.2.1/bin: is a directory
sh: /usr/local/Cellar/postgresql/9.2.1/bin: is a directory
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

steven$ sudo gem install pg -- --with-pg-config="/usr/local/Cellar/postgresql/9.2.1/bin" --with-libpqlib="/usr/local/Cellar/postgresql/9.2.1/include"
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin --with-libpqlib=/usr/local/Cellar/postgresql/9.2.1/include
Using config values from /usr/local/Cellar/postgresql/9.2.1/bin
sh: /usr/local/Cellar/postgresql/9.2.1/bin: is a directory
sh: /usr/local/Cellar/postgresql/9.2.1/bin: is a directory
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -l/usr/local/Cellar/postgresql/9.2.1/include... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

steven$ sudo gem install pg --with-pg-config="/usr/local/Cellar/postgresql/9.2.1/bin" --with-libpqlib="/usr/local/Cellar/postgresql/9.2.1/include"
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin

steven$ sudo gem install pg --with-pg-config="/usr/local/Cellar/postgresql/9.2.1/bin/" --with-libpqlib="/usr/local/Cellar/postgresql/9.2.1/include/"
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/

steven$ sudo gem install pg --with-pg-config='/usr/local/Cellar/postgresql/9.2.1/bin/' --with-libpqlib='/usr/local/Cellar/postgresql/9.2.1/include/'
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/

steven$ sudo gem install pg -- --with-pg-config='/usr/local/Cellar/postgresql/9.2.1/bin/' --with-libpqlib='/usr/local/Cellar/postgresql/9.2.1/include/'
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/ --with-libpqlib=/usr/local/Cellar/postgresql/9.2.1/include/
Using config values from /usr/local/Cellar/postgresql/9.2.1/bin/
sh: /usr/local/Cellar/postgresql/9.2.1/bin/: is a directory
sh: /usr/local/Cellar/postgresql/9.2.1/bin/: is a directory
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -l/usr/local/Cellar/postgresql/9.2.1/include/... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

steven$ sudo gem install pg --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/ --with-libpqlib=/usr/local/Cellar/postgresql/9.2.1/include
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/
iMac-001EC20A3C44-5:testivate steven$ sudo gem install pg --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/pg_config

ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-pg-config=/usr/local/Cellar/postgresql/9.2.1/bin/pg_config

私は何をすべきか?

4

2 に答える 2

2

参考までに、PostgreSQL と pg gem から Bundler、Homebrew、さらには RVM に至るまですべてをアンインストールしてから、すべてのピースを一度に 1 つずつインストールすることで、最終的にこれを解決しました。おそらく、必要以上に削除しましたが、すべてを元に戻すと、すべてが機能しました。

于 2012-10-03T20:23:10.067 に答える
1

これが他の人に役立つかどうかはわかりませんが、PG gemがコンパイルされないというまったく同じ問題がありました。私のアプリは Heroku 上にあり、ローカルでは RVM、Homebrew を使用していますが、Postgres には Postgresapp.com を使用しています

また、JewerlyBoxを使用して、RVM の優れた GUI ラッパーを提供しています。Ruby 1.9.3-p194 と 1.9.3-p286 を比較すると、286 をユニバーサルに設定していることに気付きました。すべてをアンインストールするのをためらっていたので、Ruby をアンインストールし、オプションを 64 ビットのみに設定して再インストールしました (プラットフォーム: "x86_64-darwin12.2.0")。

このオプションを使用して Ruby を再インストールした後、PG gem は問題なくインストールされ、満足できる状態に戻りました。これが誰かに役立つことを願っています。

ここに画像の説明を入力

于 2012-10-20T04:10:17.450 に答える