Rails 3 - 无法安装 pg gem [英] Rails 3 - can't install pg gem
问题描述
当我尝试运行 bundle(捆绑安装)时,我总是得到
When I try to run bundle (bundle install), I all the time get
Installing pg (0.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/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/ryan/.rvm/rubies/ruby-1.9.2-p290/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
Gem files will remain installed in /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.
我使用 Mac OS X 10.6,安装的 PostgreSQL 版本是 9.1.我发现问题出在 libpq-dev 中,我该如何安装/修复它?
I use Mac OS X 10.6, the version of installed PostgreSQL is 9.1. I found the problem is in the libpq-dev, how could I install/fix that?
推荐答案
如错误日志中所述,您需要将路径传递到 pg_config.xml 文件中.尝试使用以下方法安装 gem:
As stated in your error log you need to pass in the path to the pg_config. Try to install the gem using:
gem install pg -- --with-pg-config= 'PATH_TO_YOUR_PG_CONFIG'
如果您不确定 pg_config 在哪里,并且假设您使用的是 Linux 或 Mac,则可以运行以下命令:
If you are not sure where your pg_config is, and assuming you are on Linux or Mac, you can run the following command:
which pg_config
根据您安装 postgres 的方式,您的 pg-config 可以位于不同的位置.
Your pg-config can be in different locations depending on how you installed postgres.
这篇关于Rails 3 - 无法安装 pg gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!