【发布时间】:2013-05-22 22:31:03
【问题描述】:
在 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 上使用
【问题讨论】:
-
“我什至不打算在本地使用 postgresql”是一个非常糟糕的主意,使用不同的数据库进行开发和部署是一个非常常见的痛苦来源。不,像 ActiveRecord 这样的 ORM 不会使您免受数据库差异的影响。因此,如果您计划在 PostgreSQL 之上部署,请在本地安装 PostgreSQL 并使用 PostgreSQL 进行开发。
-
可能是duplicated
-
gem 有一个本地 C 扩展,它需要 PGSQL 安装附带的 PostgreSQL (PGSQL) 头文件。我非常怀疑您之前不需要安装 PGSQL,也许您在不知情的情况下安装了它。使用 Homebrew 安装非常简单:
brew install postgresql并按照屏幕上的说明进行操作。
标签: ruby postgresql gem ruby-1.9.3 pg