OS X El Capitan 更新后无法捆绑安装 pg gem

Unable to bundle install pg gem after OS X El Capitan Update

在尝试 bundle install 并直接使用 `sudo gem install pg -v "0.18.4"' 之后,我在尝试安装 pg [=18] 时一直 运行 出错=].在我安装 OS X El Capitan 的最新更新之前,我所有的 gem 都是 运行 完美的。我得到的错误如下:

sudo gem install pg -v '0.18.4'
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.0.0/gems/pg-0.18.4/ext
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20160502-32186-1wkopvv.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
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/2.0/usr/bin/ruby
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/pg-0.18.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.4 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/pg-0.18.4/gem_make.out

我完全不知道如何解决这个问题...

我相信如果您在系统上安装 postgresql 就可以解决这个问题。前几天我遇到了类似的错误,通过安装 homebrew 和 运行

解决了这个问题
brew install postgresql

看来您需要在系统上安装 postgresql。如果您 OSX 开始使用 PostgreSQL 最简单的方法是 Postgres.app 可以在这里找到 - Postgresapp.com

只需点击下载,即可获得 postgres,同时避免使用命令行。