无法安装pg gem

时间:2013-05-22 22:31:04

标签: ruby postgresql gem ruby-1.9.3 pg

在Mac OS X 10.6.8上,尝试gem install pg时出现以下错误。试图将我的Rails网站推送到Heroku。一个非常标准的Ruby 1.9.3p194安装。

$ cat /Users/me/.rvm/gems/ruby-1.9.3-p194\@ucode/gems/pg-0.15.1/ext/gem_make.out 
/Users/me/.rvm/rubies/ruby-1.9.3-p194/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
    --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=/Users/me/.rvm/rubies/ruby-1.9.3-p194/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

我以前从未需要在本地安装postgresql。我是否还需要安装数据库?事实上,我甚至不打算在本地使用postgresql,只是在Heroku

1 个答案:

答案 0 :(得分:2)

构建输出的第一行告诉您错误和操作:

No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config

所以....传递--with-pg-config=/wherever/your/pg_config或将其添加到PATH,以便构建可以找到它。

我也强烈赞同他的评论;使用一个数据库进行本地测试,然后使用另一个数据库远程进行测试,可以解决疼痛,痛苦和部如果SQL真的一致且标准足以使其工作,那将是可爱的,但现实是不同的。