使用Xcode 6.0.1在OSX 10.9.5上安装gem`pg`时出错

时间:2014-09-30 21:38:52

标签: ruby-on-rails ruby macos rvm bundle

运行bundle install和rails的问题将无法正确加载...尝试了我在旧Stackoverflow帖子上发现的类似问题上的所有内容无效...错误如下。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20140930-556-1w549j8.rb 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
        --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
        --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}/

extconf failed, exit code 1

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

问题是您没有安装pg。第一步是安装Postgres。

在此处执行:http://postgresapp.com/

下一步是使用所需的配置文件安装pg gem。这样做:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

您可能需要稍微更改路径以指向正确的位置。